New Year Sale 2026! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

C++ Institute CPA-21-02 Exam - 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:

0/2000 characters
Marcos
3 months ago
I agree, it's probably D, none of these!
upvoted 0 times
...
Francoise
3 months ago
I think it just won't compile at all.
upvoted 0 times
...
Carry
3 months ago
Wait, is "i??;" even valid?
upvoted 0 times
...
Roselle
4 months ago
Definitely not A, it won't print that.
upvoted 0 times
...
Catrice
4 months ago
Looks like a syntax error with "i??;"
upvoted 0 times
...
Nickolas
4 months ago
I feel like it might print "3210" if it somehow skips the error, but that doesn't seem right. I guess I need to think more about the loop structure.
upvoted 0 times
...
Giovanna
4 months ago
If I recall correctly, the code won't compile because of the "i??;" part. It seems like a syntax error to me.
upvoted 0 times
...
Jamey
4 months ago
I remember practicing a similar question where the loop decremented a variable, but this one looks different with that "??".
upvoted 0 times
...
Emily
5 months ago
I think the loop should print the numbers from 4 down to 0, but I'm not sure how the "i??;" affects it.
upvoted 0 times
...
Goldie
5 months ago
I'm pretty confident I know the answer here. The loop will print the values of i as it decrements, so the output should be "4321".
upvoted 0 times
...
Louis
5 months ago
Wait, what's that extra character at the end? I'm not sure about that part. I'll have to think it through step-by-step.
upvoted 0 times
...
Eden
5 months ago
Okay, I think I've got it. The loop will print the value of i, then decrement i until it reaches 0. So the output should be "4321".
upvoted 0 times
...
Iesha
5 months ago
This looks like a pretty straightforward loop question. I'll carefully trace the loop to see what the output will be.
upvoted 0 times
...
Helene
5 months ago
Hmm, I'm a bit confused about the i-- part. Is that a valid decrement operator? I'll need to double-check the syntax.
upvoted 0 times
...
Raina
5 months ago
Hmm, I'm a little unsure about this one. I know reinforcing consequences are supposed to decrease the likelihood of a behavior, but some of these options seem a bit ambiguous. I'll have to really analyze each one closely.
upvoted 0 times
...
Makeda
1 year 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
1 year 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 year ago
User 3: None of these
upvoted 0 times
...
Reta
1 year ago
User 2: I think it prints: '3210'
upvoted 0 times
...
Domitila
1 year ago
It prints: '3210?1'
upvoted 0 times
...
...
Magnolia
1 year ago
I'm not sure, but I think it will print '3210'
upvoted 0 times
...
Harley
1 year ago
Wait, what's that i-- thing doing? Isn't that supposed to decrement the value of i?
upvoted 0 times
...
Donte
1 year 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 year ago
C) It prints: '3210?1'
upvoted 0 times
...
Tom
1 year ago
None of these
upvoted 0 times
...
Meaghan
1 year ago
B) It prints: '3210'
upvoted 0 times
...
Samira
1 year ago
I think it prints: ''3210''
upvoted 0 times
...
Horace
1 year ago
A) It prints: '43210'
upvoted 0 times
...
Louis
1 year ago
No, it prints: ''3210''
upvoted 0 times
...
Pa
1 year ago
It prints: ''3210?1''
upvoted 0 times
...
...
Jovita
1 year ago
I agree with Gerardo, because the loop starts at 4 and goes down to 0
upvoted 0 times
...
Gerardo
1 year ago
I think it will print '3210'
upvoted 0 times
...

Save Cancel