#include <stdio.h> #include <stdlib.h> int main() { int arr[9]={1,10,20,30,40,50,60,70,80}; int number; int i,j; int entry=-1; printf("please enter number that you are looking for: "); scanf("%d",&number); while(1) { for(int i=0;i<9;i++) { if(arr[i]==number) entry=i; } if(entry==-1) { printf("\n%d does not exist in the array",number); } else { printf("\n%d does exist in the array it is entry %d: ",number,entry+1); } printf("\nplease enter another number: "); scanf("%d",&number); entry==-1; } return 0; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter