Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- int array[100];
- int i, num, key, found = 0;
- printf("Enter the value of num : ");
- scanf("%d", &num);
- printf("Enter the elements : ");
- for (i = 0; i < num; i++)
- {
- scanf("%d", &array[i]);
- }
- printf("Enter the element to be searched : ");
- scanf("%d", &key);
- for (i = 0; i < num ; i++)
- {
- if (key == array[i] )
- {
- found = 1;
- break;
- }
- }
- if (found == 1)
- printf("Element is present in the array\n");
- else
- printf("Element is not present in the array\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement