C program to search the given data from the list of element from given array
#include<stdio.h>
#include<conio.h>
main()
{
int i,n, num,flag=0;
printf("How may number you wnat to enter\n");
scanf("%d",&n);
int arr[n];
printf("Enter %d numbers\n",n);
for(i=0;i<n;i++)
{
scanf("%d",&arr[i]);
}
printf("enter the number you want to search\n");
scanf("%d",&num);
for(i=0;i<n;i++)
{
if(num==arr[i])
{
flag=1;
break;
}
}
if(flag==1)
printf("data found");
else
printf("data not found");
getch();
}
No comments:
Post a Comment