adsense

Hii, welcome to my site. My name is Om prakash kartik. This blog helps you to learn programming languages concepts.

program in C to search given number in an array .

Program in C to search given number in an array


#include<stdio.h>
#include<conio.h>
  void main()
     {
     int i,a[20],l,c=0,j,n,d;
     printf("Enter number of elements you want to insert:-");
     scanf("%d",&n);
     printf("Enter %d numbers:-",n);
     for(i=0;i<n;i++)
     scanf("%d",&a[i]);
     printf("Enter a number you want to search:-");
     scanf("%d",&d);
     for(i=0;i<n;i++)
      {
        if(a[i]==d)
          c++;
      }
       if(c>=1)
          printf("%d is present in given array.",d);
       else
         printf("%d is not present in given array.",d);
     getch();
    }
Output:-




Post a Comment

0 Comments