I have to write a function which checks if a value is located in an array with N elements using for loop.I wrote the code
#include <stdio.h>
int main ()
int N[100],n,i;
printf ("Write the value of n:");
scanf ("%d",&n);
i=0;
printf ("Write the value of the element :");
scanf ("%d",&v[i]);
for (i=0,i<n,i++)
{
if (N[i]==n)
}
printf ("The value is located in the array :");
return 0;
When I compile it,it says syntax error before printf.What does this mean?What have I done wrong?
printfwith brackets{ printf();}. You also have to close the bracket for theforloop. And where are the brackets for themain?printfisn't going to solve this problem. To start with, your entiremainfunction needs brackets; the syntax is something likeint main () { ...code goes here... }.