Computer Science, asked by sayalidoshi315, 16 days ago

Write a program to search an given value in an one-dimensional array​

Answers

Answered by gidigamshivani2008
2

Answer:

30

#include <stdio.h>

#include <conio.h>

int main()

{

int a[10000],i,n,key;

printf("Enter size of the array : ");

scanf("%d", &n);

printf("Enter elements in array : ");

for(i=0; i<n; i++)

{

scanf("%d",&a[i]);

}

printf("Enter the key : ");

scanf("%d", &key);

for(i=0; i<n; i++)

{

if(a[i]==key)

{

printf("element found ");

return 0;

}

}

printf("element not found");

Explanation:

Output:

1

2

3

4

5

6

7

8

Enter size of the array: 5

Enter elements in array: 4

6

2

1

3

Enter the key: 2

element found

Similar questions