Linear search this C program used for search elements easily to use this program and let's enjoy this program
Output:
Enter size of array
6
Enter the numbers
78
30
35
21
10
-102
Enter the element to be searched
-102
Search SuccessfulExplanation:
//Coming Soon..
#include<stdio.h> main() { int i,n,search,flag=0; printf("Enter size of array\n"); scanf("%d",&n); int a[n]; printf("Enter the numbers\n"); for(i=0;i<n;i++) { scanf("%d",&a[i]); } printf("Enter the element to be searched\n"); scanf("%d",&search); for(i=0;i<n;i++) { if(a[i]==search) { flag=1; } } if(flag==1) { printf("Search Successful\n"); } else { printf("Search is not Successful\n"); } }
Enter size of array
6
Enter the numbers
78
30
35
21
10
-102
Enter the element to be searched
-102
Search SuccessfulExplanation:
//Coming Soon..
No comments:
Post a Comment