Code in C to perform iterative linear search
Answers
Answered by
1
Answer:
Linear search C program
#include <stdio.h>
int main()
{
int array[100], search, c, n;
printf("Enter number of elements in array\n");
scanf("%d", &n);
printf("Enter %d integer(s)\n", n);
for (c = 0; c < n; c++)
scanf("%d", &array[c]);
printf("Enter a number to search\n");
scanf("%d", &search);
for (c = 0; c < n; c++)
{
if (array[c] == search) /* If required element is found */
{
printf("%d is present at location %d.\n", search, c+1);
break;
}
}
if (c == n)
printf("%d isn't present in the array.\n", search);
return 0;
}
mark brainliest
Similar questions
Math,
6 months ago
Social Sciences,
6 months ago
Math,
6 months ago
Geography,
11 months ago
Political Science,
11 months ago
Art,
1 year ago
CBSE BOARD X,
1 year ago
Math,
1 year ago