In this code for linear search, after line 8 is executed it jumps to line 13 without executing the for loop.
Output: Enter the size of array 5 Enter the elements Enter the element to be searched
Here is the code:
#include<stdio.h>
int main()
{
int array[100],search,c,n;
printf("Enter the size of array\n");
scanf("%d",&n);
printf("Enter the elements:\n");
for(c=0; c>n; c++)
{
scanf("%d",&array[c]);
}
printf("Enter the no. to be searched\n");
scanf("%d",&search);
for(c = 0; c>n; c++)
{
if(array[c] == search)
{
printf("%d is at location %d\n",search,c);
break;
}
if(c == n)
printf("Item not found\n");
}
return 0;
}