Write a program to search an given value in an one-dimensional array
Answers
Answered by
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
Hindi,
8 days ago
Physics,
8 days ago
Science,
16 days ago
Math,
16 days ago
Social Sciences,
8 months ago
Social Sciences,
8 months ago