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;
}
Suggested Answer: A
Get Premium CPA-21-02 Questions
as Interactive Web-Based Practice Test or PDF
Real Exam Format
Detailed Explanations
Instant Access
Get Your Practice Test
32 comments · newest first
MA
Marcos
10 months ago
I agree, it's probably D, none of these!
FR
Francoise
11 months ago
I think it just won't compile at all.
CA
Carry
11 months ago
Wait, is "i??;" even valid?
RO
Roselle
11 months ago
Definitely not A, it won't print that.
CA
Catrice
11 months ago
Looks like a syntax error with "i??;"
NI
Nickolas
12 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.
GI
Giovanna
12 months ago
If I recall correctly, the code won't compile because of the "i??;" part. It seems like a syntax error to me.
JA
Jamey
12 months ago
I remember practicing a similar question where the loop decremented a variable, but this one looks different with that "??".
EM
Emily
1 year ago
I think the loop should print the numbers from 4 down to 0, but I'm not sure how the "i??;" affects it.
GO
Goldie
1 year 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".
LO
Louis
1 year 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.
ED
Eden
1 year 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".
IE
Iesha
1 year ago
This looks like a pretty straightforward loop question. I'll carefully trace the loop to see what the output will be.
HE
Helene
1 year 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.
RA
Raina
1 year 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.
MA
Makeda
2 years 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'.
IL
Iluminada
2 years 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.
TH
Therese
2 years ago
User 3: None of these
RE
Reta
2 years ago
User 2: I think it prints: '3210'
DO
Domitila
2 years ago
It prints: '3210?1'
MA
Magnolia
2 years ago
I'm not sure, but I think it will print '3210'
HA
Harley
2 years ago
Wait, what's that i-- thing doing? Isn't that supposed to decrement the value of i?
DO
Donte
2 years 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?
NO
Noah
2 years ago
C) It prints: '3210?1'
TO
Tom
2 years ago
None of these
ME
Meaghan
2 years ago
B) It prints: '3210'
SA
Samira
2 years ago
I think it prints: ''3210''
HO
Horace
2 years ago
A) It prints: '43210'
LO
Louis
2 years ago
No, it prints: ''3210''
PA
Pa
2 years ago
It prints: ''3210?1''
JO
Jovita
2 years ago
I agree with Gerardo, because the loop starts at 4 and goes down to 0
GE
Gerardo
2 years ago
I think it will print '3210'