Write a program to search an element in an array of n elements.
# include
# include
void main()
{
int a[50],n,i,s,flag=0;
clrscr();
printf("\nEnter the total numbeer of elements in the array:");
scanf("%d",&n);
for(i=0;i
printf("\nEnter the value of %d:",i+1);
scanf("%d",&a[i]);
}
printf("\nEnter the value that has to be searched in the array:");
scanf("%d",&s);
for(i=0;i
if(a[i]==s)
{
flag=1;
printf("\nValue Found in location %d",i+1);
break;
}
else
flag=0;
}
if(flag==0)
printf("Value not found");
getch();
}
/*Output
Enter the total numbeer of elements in the array:2
Enter the value of 1:66
Enter the value of 2:69
Enter the value that has to be searched in the array:69
Value Found in location 2
*/
Shopping In MUMBAI
Are you searching for Discounts, offers, sale in Mumbai ? You are in the right place. MUMBAI, a shopping haven, has no dearth of great discounts and sales. This blog features the best MUMBAI shopping offers, sale, discounts and deals and bargains CURRENTLY GOING on in Mumbai plus a few free things thrown in on top.
Don't wait for it because once they are gone, they are gone. Hurry!..By clicking the "Like" button you will receive a daily update of discounts, sale, offers going on in Mumbai. LIKE IT.... SHARE IT...njoY.
Tuesday, December 30, 2008
C program to search an element in an array of n elements.
Posted by ars at 12:10 AM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment