Bird
0
0

Which of the following correctly shows the structure of a C program that includes a header, a global variable, and main function?

hard📝 Application Q9 of 15
C - Basics and Execution Environment
Which of the following correctly shows the structure of a C program that includes a header, a global variable, and main function?
A#include <stdio.h> int count = 0; int main() { printf("Count: %d", count); return 0; }
Bint main() { int count = 0; #include <stdio.h> printf("Count: %d", count); return 0; }
C#include <stdio.h> int main() { int count = 0; printf("Count: %d", count); return 0; } int count = 0;
Dint count = 0; int main() { printf("Count: %d", count); return 0; } #include <stdio.h>
Step-by-Step Solution
Solution:
  1. Step 1: Understand correct order of program parts

    Header files come first, then global variables, then main function.
  2. Step 2: Check each option for correct order

    #include int count = 0; int main() { printf("Count: %d", count); return 0; } follows correct order; others mix header and variables incorrectly.
  3. Final Answer:

    Header, global variable, then main function in order -> Option A
  4. Quick Check:

    Correct program structure order = #include int count = 0; int main() { printf("Count: %d", count); return 0; } [OK]
Quick Trick: Headers first, globals next, then main() function [OK]
Common Mistakes:
  • Placing #include inside main
  • Declaring globals after main

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes