Write a program in C for searching the element in an array
#include <stdio.h>
#include <conio.h>
void main()
{
int j=0,n,x[5];
clrscr();
printf(“enter the elements of array\n”);
for(j=0;j<5;j++)
scanf(“%d”,&x[j]);
printf(“enter the element to search\n”);
scanf(“%d”,&n);
for(j=0;j<5;j++)
{
if(x[j]==n)
break;
}
if(x[j]==n)
printf(“element found”);
else
printf(“element not found”);
getch();
}
Post a Comment