Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

C++ Institute CLA-11-03 Exam - Topic 2 Question 7 Discussion

Posted by Chantell on Oct 14, 2026 at 02:02 PM

What happens if you try to compile and run this program?

#include

int fun(int i) {

return i++;

}

int main (void) {

int i = 1;

i = fun(i);

printf("%d",i);

return 0;

}

Choose the correct answer:

Suggested Answer: D

In the fun function:

cCopy code

int fun(int i) { return i++; }

The post-increment operator i++ returns the current value of i and then increments it. So, fun(i) will return the current value of i (which is 1) and then increment i to 2.

In the main function:

cCopy code

int i = 1; i = fun(i); printf('%d', i);

Here, i is assigned the result of fun(i), which is 1. So, the program prints the value of i, which is 1.

Therefore, the correct answer is D. The program outputs 1.


Get Premium CLA-11-03 Questions as Interactive Web-Based Practice Test or PDF Real Exam Format Detailed Explanations Instant Access Get Your Practice Test
1 comments · newest first
AN
Antonio 1 day ago
I think the function returns the value of `i` before the increment, so it should output 1.
0/2000 characters

Save Cancel