Discussion :: C-MCQs
-
Does this compile without error?
int main()
{
for (int k = 0; k < 10; k++);
return 0;
}
Answer : Option C
Explanation :
Compilers implementing C90 does not allow this but compilers implementing C99 allow it.
Output:
$ cc pgm4.c
pgm4.c: In function 'main':
pgm4.c:4: error: 'for' loop initial declarations are only allowed in C99 mode
pgm4.c:4: note: use option -std=c99 or -std=gnu99 to compile your code
Be The First To Comment