#include<stdio.h>
#include<conio.h>
void
main()
{
int arr[10],i,element,flag=0;
clrscr();
/* To enter elements in a 1-D array */
printf("Enter the elements of the
array:\n");
for(i=0;i<10;i++)
{
scanf("%d",&arr[i]);
}
printf("\nEnter the element to be
searched:");
scanf("%d",&element);
/* Searching */
for(i=0;i<10;i++)
{
if(arr[i] == element)
{
flag=1;
break;
}
}
if(flag == 1)
printf("\nElement found!");
else
printf("\nElement NOT found!");
getch();
}
OUTPUT
Enter
the elements of the array:
24
32
36
52
48
56
82
94
38
58
Enter
the element to be searched:48
Element
found!
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.