#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,search,count=0;
printf("\n\t Enter number of element in array");
scanf("%d",&n);
int arr[n];
printf("\n\t Enter %d number",n);
for(i=0;i<n;i++)
{
scanf("%d",&arr[i]);
}
printf("\n\t Enter a number to search");
scanf("%d",&search);
for(i=0;i<n;i++)
{
if(arr[i]==search)
{
printf("\n\t %d present at location %d",search,(i+1));
count++;
}
}
if(count==0)
{
printf("\n\t %d is not present in array ",search);
}
else
{
printf("\n\t %d is present %d times in array",search,count);
}
}
Output:
Enter number of element in array 7
Enter 7 number 10 12 15 76 59 45 57
Enter a number to search 10
10 present at location 1
10 is present 1 times in array
Program:
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer