Question:

Consider the following statements in C to write a program in their order of occurrence :
A. Printf("%d", i);

B. void main ( )

C. int i=5;

D. #include <stdio.h>

Choose the correct answer from the options given below :

Show Hint

Remember the skeleton: Include $\to$ Main $\to$ Declare $\to$ Execute. You can't use a tool (printf) without its manual (stdio.h), and you can't print a variable (i) before you create it!
Updated On: Aug 6, 2026
  • D, B, C, A
  • B, D, C, A
  • B, C, A, D
  • D, B, A, C
Show Solution
collegedunia
Verified By Collegedunia

The Correct Option is A

Solution and Explanation

Concept:
• A C program follows a strict structural hierarchy required by the compiler.
• Components must be declared or defined before they are used in statements.

Step 1:
Preprocessor Directives (D)
The #include statement must come first so that the compiler can load definitions for standard functions like printf.

Step 2:
Function Definition (B)
The entry point of every C program is the main() function. It follows the include section.

Step 3:
Variable Declaration and Initialization (C)
Inside the main function, variables must be declared (and optionally initialized) before any logic uses them.

Step 4:
Executable Statements (A)
The actual logic, such as printing the value of the variable, comes after variables are initialized.

Step 5:
Synthesize the code
#include <stdio.h> void main() { int i = 5; printf("%d", i); Sequence: D \(\rightarrow\) B \(\rightarrow\) C \(\rightarrow\) A.
Was this answer helpful?
0
0

Top CUET PG Data Science A.I Cyber Security and Computer Sci. Questions

View More Questions

Top CUET PG Programming and Data Structures Questions

View More Questions