What will the output of the following C code be? #include void main() int k = 4; float k = 4; printf("percent d", k)
A. Compile time error
B. 4
C. 4.0000000
D. 4.4
Answer:A
What will the output of the following C code be? #include void main() int k = 4; float k = 4; printf("percent d", k)
A. Compile time error B. 4 C. 4.0000000 D. 4.4
Explanation: It results in an error because the variable k is declared as both an integer and a float. 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 'percent d' expects type 'int,' but argument 2 has type 'double' pgm8.c:7: error: expecting ';' before " token