Program in C to search given number in an array
#include<stdio.h> #include<conio.h> void main() { int i,a[20],l,c=0,j,n,d; printf("Enter number of elements you want to insert:-"); scanf("%d",&n); printf("Enter %d numbers:-",n); for(i=0;i<n;i++) scanf("%d",&a[i]); printf("Enter a number you want to search:-"); scanf("%d",&d); for(i=0;i<n;i++) { if(a[i]==d) c++; } if(c>=1) printf("%d is present in given array.",d); else printf("%d is not present in given array.",d); getch(); }Output:-
0 Comments