C program to search a particular number in an array.
#include <stdio.h>
int main()
{
int arr[10]={3,5,4,7,8,1,12,18,6,10};
int n,i,found=0;
printf("Enter a number you want to search : ");
scanf("%d",&n);
for(i=0;i<10;i++)
{
if(arr[i] == n)
{
found = 1;
break;
}
}
if(found == 1)
printf("YES, Number is present in the array");
else
printf("No, Number is NOT present in the array");
return 0;
}
OUTPUT:
(1st RUN)
Enter a number you want to search : 7
YES, Number is present in the array
(2nd RUN)
Enter a number you want to search : 9
No, Number is NOT present in the array
Array programs
- Sequence filter in array in C
- Array Search (Linear search)
- Array Merging
- Array Sorting
- C program to take marks and show percentage accordingly.
- C program to take user input to an array and show its content.
- C program to search an element in the array using a user – defined function.
- C program to search an element in the array using bsearch() function.
- C program to sort an array using qsort() functions.
- Recursive binary search in C.