Thursday, September 13, 2012

Find element in array and its repetition in one dimensional Array C program

Find element in array and its repetition in one dimensional Array C program

Program to accept elements in array then take input from user to find that element and its repetition in Single Dimensional Array



#include<stdio.h>

int main()
{
int a[100],i,no,n,c=0;
printf("\nPlease Enter Value of n:\t");
scanf("%d",&n);
printf("\nPlease Enter %d numbers in array:\n",n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("\nPlease enter no to be Search:\n");
scanf("%d",&no);
for(i=0;i<n;i++)
{
 if(a[i]==no)
 {c++;}
}
if(c==0)
{
printf("\nGiven No is Not Present...!!\n");
}
else
{
printf("\n%d present %d times in array\n",no,c);
}
return 0;
}

0 comments:

Post a Comment