SEARCHING IN ARRAY
C PROGRAM TO SEARCHING IN ARRAY
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a[10];
int i, num;
printf("Enter values in array:\n");
for(i=0; i<10; i++)
{
scanf("%d", a[i]);
}
printf("Enter value to search :");
scanf("%d",&num);
// Loop to search entered value's position in array
for(i=0; i<10; i++)
{
if(num == a[i])
{
break;
}}
printf("Value found at position: %d", i+1);
getch();
}
----------------------------
OUTPUT
----------------------------
Enter values in array:
16
17
13
14
18
11
12
15
10
Enter value to search: 13
Value found at position: 3
0 Comments