#include<stdio.h>
int main(){
int a[20],i,n,s,var=0;
printf("Enter the size of an array: ");
scanf("%d",&n);
printf("Enter the elements of the array: ");
for(i=0;i<=n-1;i++){
scanf("%d",&a[i]);
}
printf("Enter the Element to be searched: ");
scanf("%d",&s);
for(i=0;i<=n-1;i++){
if(a[i]==s){
var=1;
break;
}
}
if(var==0)
printf("The number is not in the list");
else
printf("The element is found");
return 0;
}
output:
Enter the size of an array: 6
Enter the elements of the array: 5 8 9 1 3 4
Enter the Element to be searched: 9
The Element is found
No comments:
Post a Comment