doubt in program not getting the mistake

binary-search
linear

#1

#include<stdio.h>
int linearsearch(int a[5],int r,int e)
{
int i;
for(i=0;i<r;i++)
{
if(e==a*)
return 1;
}
}
int main()
{
int r;
printf(“enter the size of array
“);
scanf(”%d”,&r);
int a[5];
for(i=0;i<r;i++)
scanf("%d",&a*);
printf(“enter the value to be searched”);
int e;
scanf("%d",&e);
int flag=linearsearch(a,r,e);
if (flag==1)
printf(“element found”);
else
printf(“element not found”);
}

NOT GETTING MISTAKE…WATS THE MISTAKE


#2

Did you try returning a number that is not 1, from linearsearch, after the for loop?

Something like

int linearsearch(int a[5],int r,int e)
{
    int i;
    for(i=0;i<r;i++)
    {
        if(e==a*)
        return 1;
    }
    return 0; // right here
}

#3

in linearsearch()
,u didn’t returned value if e!=a*.
in main()
,this will only work for <=5 elements and give error if r>5.
I have just checked ur syntax error.
I would suggest u need to study C properly and use codeblocks for writing codes which shows error lines.