C Program to search a number in an array

Problem Statement

Write a program in C to search for a given number within the array.

How to search for an given number in an array ?

#include <stdio.h> 
int main() 
{ 
   int arr[250], search, n, i; 
   printf("Enter the number is elements in the array\n"); 
   scanf("%d",&n); 
  
   printf("\nEnter %d number one by one", n); 
  
   for (i = 0; i < n; i++) 
      scanf("%d", &arr[i]); 
  
   printf("\nEnter the number to search"); 
   scanf("%d", &search); 
  
   for (i = 0; i < n; i++) 
   { 
      if (arr[i] == search)   
      { 
         printf("\n%d is found at index %d\n", search, i+1); 
         break; 
      } 
   } 
   if (i == n) 
      printf("%d is not found in the array.\n", search); 
   return 0; 
}