C. Missing return value in main's return statement
D. main function missing parentheses
Solution
Step 1: Check the return statement in main
Main returns int, so return must have a value like 0. Here, return is used without a value.
Step 2: Verify other parts of code
Semicolon after cout is present, header is correct, and main has parentheses.
Final Answer:
Missing return value in main's return statement -> Option C
Quick Check:
int main() must return int value = A [OK]
Hint: int main() must return an int value [OK]
Common Mistakes:
Using return without value in int main
Assuming void main is valid
Ignoring missing return value errors
5. You want your C++ program to return 1 to the operating system when it finishes. Which main function code correctly does this?
hard
A. int main() { return 1; }
B. void main() { return 1; }
C. int main() { return; }
D. int main() { return '1'; }
Solution
Step 1: Understand return type and value
Main returns int, so return value must be an integer. Returning 1 signals a specific exit code.
Step 2: Check each option for correctness
int main() { return 1; } returns integer 1 correctly. void main() { return 1; } uses void main which is non-standard. int main() { return; } returns nothing. int main() { return '1'; } returns a char, not int.
Final Answer:
int main() { return 1; } -> Option A
Quick Check:
Return integer 1 from main = D [OK]
Hint: Return integer value from int main() [OK]
Common Mistakes:
Using void main instead of int main
Returning no value or wrong type
Returning character instead of integer
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.