Cyber Monday 2024! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

C++ Institute Exam CPA-21-02 Topic 7 Question 27 Discussion

Actual exam question for C++ Institute's CPA-21-02 exam
Question #: 27
Topic #: 7
[All CPA-21-02 Questions]

What happens when you attempt to compile and run the following code?

#include

using namespace std;

int main()

{

int i = 4;

while(i >= 0) {

cout<

i??;

}

return 0;

}

Show Suggested Answer Hide Answer
Suggested Answer: A

Contribute your Thoughts:

Makeda
2 months ago
Hmm, I think the answer is B. The post-decrement operator will cause the value of i to be printed first, and then it will be decremented. So the output should be '3210'.
upvoted 0 times
...
Iluminada
2 months ago
Haha, that's a classic one! I remember getting tripped up by the post-decrement operator before. This is going to be a good test of our attention to detail.
upvoted 0 times
Therese
1 months ago
User 3: None of these
upvoted 0 times
...
Reta
1 months ago
User 2: I think it prints: '3210'
upvoted 0 times
...
Domitila
1 months ago
It prints: '3210?1'
upvoted 0 times
...
...
Magnolia
2 months ago
I'm not sure, but I think it will print '3210'
upvoted 0 times
...
Harley
2 months ago
Wait, what's that i-- thing doing? Isn't that supposed to decrement the value of i?
upvoted 0 times
...
Donte
3 months ago
Okay, let's think this through. The code is incrementing the value of i by 1 in each iteration, so it should print the numbers in descending order, right?
upvoted 0 times
Noah
1 months ago
C) It prints: '3210?1'
upvoted 0 times
...
Tom
1 months ago
None of these
upvoted 0 times
...
Meaghan
2 months ago
B) It prints: '3210'
upvoted 0 times
...
Samira
2 months ago
I think it prints: ''3210''
upvoted 0 times
...
Horace
2 months ago
A) It prints: '43210'
upvoted 0 times
...
Louis
2 months ago
No, it prints: ''3210''
upvoted 0 times
...
Pa
2 months ago
It prints: ''3210?1''
upvoted 0 times
...
...
Jovita
3 months ago
I agree with Gerardo, because the loop starts at 4 and goes down to 0
upvoted 0 times
...
Gerardo
3 months ago
I think it will print '3210'
upvoted 0 times
...

Save Cancel
az-700  pass4success  az-104  200-301  200-201  cissp  350-401  350-201  350-501  350-601  350-801  350-901  az-720  az-305  pl-300  

Warning: Cannot modify header information - headers already sent by (output started at /pass.php:70) in /pass.php on line 77