counter

Free Hit Counter

Search no. in array

Q: nos are entered thru the keyboard and the no. searched by the user is displayed if it is present in the array


#include
#include
void main()
{
int a[25],i,n,c=0;
clrscr();
for(i=0;i<5;i++)
{
printf("enter any no.:");
scanf("%d",&a[i]);
}
printf("Enter the no. to be searched:");
scanf("%d",&n);
for(i=0;i<=5;i++)
{

if(n==a[i])
c++;
}
if(c>0)
{
printf("%d\n",n);
printf("the no is present %d times",c);
}
else
printf("no. not present in array");
getch();
}



No comments:

Post a Comment