Advertisement
shawonrog

p3

Apr 11th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdio.h>
  2.  main()
  3.  {
  4.    int array[100], search, c, number;
  5.    
  6.    printf("Enter the number of elements in array: \n");
  7.    scanf("%d",&number);
  8.    
  9.    printf("Enter %d numbers : \n", number);
  10.    for ( c = 0 ; c < number ; c++ )
  11.         scanf("%d",&array[c]);
  12.      
  13.    printf("Enter the number to Search : \n");
  14.    scanf("%d",&search);
  15.    
  16.    for ( c = 0 ; c < number ; c++ )
  17.    {
  18.      if ( array[c] == search )
  19.      {
  20.        printf("%d - is present at location - %d\n", search, c+1);
  21.        break;
  22.      }
  23.    }
  24.    
  25.    if ( c == number )
  26.      printf("%d - is not present in array.\n", search);
  27.    return 0;
  28.    
  29.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement