#include<stdio.h> int main(){ int a[10],n=10,i,find; for(i=0;i<n;i++){ printf("Enter %d element ",i+1); scanf("%d",&a[i]); } printf("\n Enter element you want to find "); scanf("%d",&find); for(i=0;i<n;i++){ if(a[i]==find){ printf("Element Found"); break; } } if(a[i]!=find){ printf("Element Not exist"); } return 0; }ALGORITHM
STEP 1:read a[n]STEP 2:Repeat for i=1 to n step by oneif(a[i]=x)thenbreak Go to step 3end ifend forSTEP 3:if i<=nthenwrite "yes"elsewrite "No"end ifOutput
HTML
Tech News
Ad
Linear search simple program in c | how to implement linear search from algoithm
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment