fork download
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. int array[100], search, c, n;
  6.  
  7. printf("Enter the number of elements in array\n");
  8. scanf("%d",&n);
  9.  
  10. printf("Enter %d integer(s)\n", n);
  11.  
  12. for (c = 0; c < n; c++)
  13. scanf("%d", &array[c]);
  14.  
  15. printf("Enter the number to search\n");
  16. scanf("%d", &search);
  17.  
  18. for (c = 0; c < n; c++)
  19. {
  20. if (array[c] == search) /* if required element found */
  21. {
  22. printf("%d is present at location %d.\n", search, c+1);
  23. break;
  24. }
  25. }
  26. if (c == n)
  27. printf("%d is not present in array.\n", search);
  28.  
  29. return 0;
  30. }
Success #stdin #stdout 0s 10320KB
stdin
Standard input is empty
stdout
Enter the number of elements in array
Enter 0 integer(s)
Enter the number to search
0 is not present in array.