Bird
0
0

Why is the return type of main() usually int in C programs?

hard📝 Conceptual Q10 of 15
C - Basics and Execution Environment
Why is the return type of main() usually int in C programs?
ATo print output on the screen
BTo return an exit status to the operating system
CTo declare main as a void function
DTo allocate memory for the program
Step-by-Step Solution
Solution:
  1. Step 1: Understand the role of main's return value

    The return value of main is used to indicate success or failure to the operating system.
  2. Step 2: Match the purpose with the correct option

    Returning an int allows the program to send an exit status code back to the OS.
  3. Final Answer:

    To return an exit status to the operating system -> Option B
  4. Quick Check:

    Main returns exit status = int return type [OK]
Quick Trick: int main returns status code to OS after program ends [OK]
Common Mistakes:
  • Thinking main prints output
  • Confusing return type with void
  • Assuming return allocates memory

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes