Advertisement

This array search a number from given numbers::


#include<stdio.h>
#include<conio.h>
void main()
{ clrscr();
  int a[100],i,j,n,m;
  j=0;
  printf("How many number u want to search?=");
  scanf("%d",&n);
  printf("Enter that numbers=");
  for(i=0;i<n;i++)
{  scanf("%d",&a[i]);    }
  printf("Enter a number for search=");
  scanf("%d",&m);
  for(i=0;i<n;i++)
{  if(m==a[i])
  j++;   }
  if(j==0)
  printf("search result is empty");
  else
  printf("search result is found %d time(s)",j);
  getch();
}

No comments:

Post a Comment

Please comment bellow. Share your knowledge