Pick the best statement for the following program.
#include "stdio.h" int foo(int a) { printf("%d",a); return 0; } int main() { foo; return 0; } |
(A) It’ll result in compile error because foo is used without parentheses.
(B) No compile error and some garbage value would be passed to foo function. This would make foo to be executed with output “garbage integer”.
(C) No compile error but foo function wouldn’t be executed. The program wouldn’t print anything.
(D) No compile error and ZERO (i.e. 0) would be passed to foo function. This would make foo to be executed with output 0.
Answer: (C)
Explanation: In C, if a function name is used without parentheses, the reference to the function name simply generates a pointer to the function, which is then discarded. So the above program would compile but won’t print anything.
Quiz of this Question
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
Recommended Posts:
- C Quiz - 109 | Question 1
- C Quiz - 109 | Question 3
- C Quiz - 109 | Question 4
- C Quiz - 109 | Question 5
- C Quiz - 101 | Question 1
- C Quiz - 101 | Question 2
- C Quiz - 101 | Question 3
- C Quiz - 101 | Question 4
- C Quiz - 101 | Question 5
- C Quiz - 102 | Question 1
- C Quiz - 102 | Question 2
- C Quiz - 102 | Question 3
- C Quiz - 102 | Question 4
- C Quiz - 102 | Question 5
- C Quiz - 103 | Question 1
- C Quiz - 103 | Question 2
- C Quiz - 103 | Question 3
- C Quiz - 103 | Question 4
- C Quiz - 103 | Question 5
- C Quiz - 104 | Question 1

