Code in C++ :
#include<stdio.h>
int main(){
int n,arr[50],f,x;
printf("Size of Array:");
scanf("%d",&n);
printf("ENTER ARRAY :");
for(int i=0;i<n;i++){
scanf("%d",&arr[i]);
}
printf("Which Number you want to search:");
scanf("%d",&f);
for(int i=0;i<n;i++){
if(arr[i]==f){
x=i;
break;
}
else
x= -1;
}
if(x!=-1){
printf("Found ! position:%d",x);
}
else
printf("Not Found!!");
return 0;
}
OUTPUT:
Size of Array:5
ENTER ARRAY :3
4
76
2
19
Which Number you want to search:76
Found ! position:2
Comments
Post a Comment