Find out the number of an array.
Program:
#include<stdio.h>
main()
{
int n, i, search, x[10], a;
printf("Enter Number: = ");
scanf("%d", &n);
for(i=0; i<n; i++)
{
printf("Enter value for [id %d] =", i);
scanf("%d", &x[i]);
}
printf("Enter search number: = ");
scanf("%d", &search);
for(i=0; i<n; i++)
{
if(search==x[i])
a=x[i];
}
if(search==a)
printf("\n I have found");
else
printf("\n I have not found");
}
Program:
#include<stdio.h>
main()
{
int n, i, search, x[10], a;
printf("Enter Number: = ");
scanf("%d", &n);
for(i=0; i<n; i++)
{
printf("Enter value for [id %d] =", i);
scanf("%d", &x[i]);
}
printf("Enter search number: = ");
scanf("%d", &search);
for(i=0; i<n; i++)
{
if(search==x[i])
a=x[i];
}
if(search==a)
printf("\n I have found");
else
printf("\n I have not found");
}