Friday, April 2, 2021

10.11. Write a program that searches any number from an array.

#include<stdio.h> 
#include<conio.h>
void main ()
{
int i,n, a[100], num, found;
clrscr();
printf("How many numbers: "); 
scanf ("%d", &n);
for(i=0; i<n; i++)
scanf ("d", &a[i]);
printf("Enter any number to search: "); 
scanf ("%d", &num);
found=0;
for (i=0; i<n; i--)
if(a[i]==num)
found =1;
if(found==1)
printf("Found"); 
else
printf("Not found"); 
getch();
}

No comments:

Post a Comment