C Program To Search A Number In Array
♣ Try it Out ::
#include<stdio.h> #include<conio.h> main() { int Array[] = {9, 5, 2, 10, 6, 1}; int Size = sizeof(Array) / sizeof(int); int Search, i; printf("Entered array is: \n"); for(i=0; i<Size; i++) printf("%d ", Array[i]); printf("\nEnter the number to search: "); scanf("%d", &Search); for(i=0; i<Size; i++) if(Array[i] == Search) break; if(i == Size) printf("%d is not present in array. \n", Search); else printf("%d is present at location %d. \n", Search, i+1); getch(); return(0); }
♣ Output ::
Entered array is: 9 5 2 10 6 1 Enter the number to search: 6 6 is present at location 5.
♣ Downloads ::
Comments
Post a Comment