Show Mobile Navigation

Wednesday, August 29, 2012

Array Operation Insertion, Display, Searching, Delation

Ashok royal - 00:03
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],i,e,l,flag;
clrscr();

//-----------------insertion------------------------------------------

printf("\n\n\n\nEnter Array Elements");

for(i=0;i<10;i++)
{
scanf("%d",&a[i]);
}
//--------------------------display--------------------------------

printf("\n Display Array :");

for(i=0;i<10;i++)
{
printf("  %d",a[i]);
}

printf("\n\nEnter the element to be searched :");
scanf("%d",&e);

for(i=0;i<10;i++)
{
if(e==a[i])
{
flag=1;
break;
}
}
//---------------------------------searching-------------------------

if(flag==1)
printf("\n Element found at postion :%d",i+1);

else
printf("\n Element not found");


//----------------------------delation-----------------------------

printf("\n\nEnter Element which to be delete :");
scanf("%d",&e);

for(i=0;i<10;i++)
{
if(e==a[i])
{
break;
}
for(i=e-1;i<10;i++)
{
a[i]=a[i+1];
}
}

printf(" Element %d deleted & New array is  :",e);
for(i=0;i<9;i++)
{
printf("  %d",a[i]);
}
getch();
}

0 comments:

Post a Comment

Comments : Read Them Or Add One to promote us