Search Array Elements Program in C

Advertisements

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

Google Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements