Search Array Elements Program in C


Prev Tutorial Next Tutorial

Search an Array Elements Program in C

For search array element you need to compare all array element with that particular elements.

Search Array Elements Program in C

#include<stdio.h>
#include<conio.h>

void main()
{
int i,a[50],num,size;
clrscr();
printf("Enter size of array: ");
scanf("%d",&size);
printf("Enter any %d element in array: \n",size);
for(i=0; i<size; i++)
{
scanf("%d",&a[i]);
}
printf("Enter number for find their position: ");
scanf("%d",&num);
for(i=0; i<size; i++)
{
if(a[i]==num)
{
printf("\n index of %d is  %d",num,i);
}
}
getch();
}

Output

Enter size of array: 5
Enter any 5 elements in array:
10
50
30
60
20
Enter number for find their position: 60
index of 20 is 3

Prev Tutorial Next Tutorial



Download Projects

Advertisements

FREE Online Google Play APK Downloader

Buy APP Installs, Buy 100% Genuine Installs