Discussion :: C-MCQs
-
What is the output of this C code?
void main()
{
int k = 4;
float k = 4;
printf("%d", k)
}
Answer : Option A
Explanation :
Since the variable k is defined both as integer and as float, it results in an error.
Output:
$ cc pgm8.c
pgm8.c: In function 'main':
pgm8.c:5: error: conflicting types for 'k'
pgm8.c:4: note: previous definition of 'k' was here
pgm8.c:6: warning: format '%d' expects type 'int', but argument 2 has type 'double'
pgm8.c:7: error: expected ';' before '}' token
Be The First To Comment