Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int n,arr[100];
- printf("Enter the number of element(upto 100) and elements with spaces\n");
- scanf("%d",&n);
- for(int i=0 ; i<n ; i++){
- scanf("%d",&arr[i]);
- }
- int check=0,i,find;
- printf("Enter the number you want to find\n");
- scanf("%d",&find);
- for(i=0 ; i<n ; i++){
- if(arr[i]==find){
- check = 1;
- break;
- }
- }
- if(check){
- printf("Element %d is at %d position in the array",find,i+1);
- }
- else printf("Not found");
- return 0;
- }
- /*
- Output->
- Enter the number of element and elements with spaces
- 3
- 44 55 66
- Enter the number you want to find
- 12
- Not found
- Enter the number of element and elements with spaces
- 3
- 44 55 66
- Enter the number you want to find
- 66
- Element 66 is at 3 position in the array
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement