How many times will "HELLO" be printed?
#include
using namespace std;
int main()
{
for(int i=?1; i<=10; i++)
{
if(i < 5)
continue;
else
break;
cout<<"HELLO";
}
return 0;
}
Suggested Answer: A, B
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
34 comments · newest first
AD
Adelle
11 months ago
0 is definitely the right answer here.
TH
Thora
11 months ago
Yup, the continue statement skips everything below it for i < 5.
KR
Kristel
11 months ago
Wait, are you sure? I thought it would print at least once.
RE
Regenia
11 months ago
Totally agree, the loop breaks before printing!
ME
Merlyn
11 months ago
It will print "HELLO" 0 times.
GO
Goldie
12 months ago
I feel like it might print "HELLO" twice if the loop starts at 1, but I need to double-check how the break works in this context.
TR
Tracey
12 months ago
If I remember correctly, the continue statement skips the rest of the loop for values less than 5, so maybe "HELLO" won't be printed at all?
TA
Tandra
12 months ago
I remember practicing a similar question where the loop had a break statement, but I can't recall how it affected the output here.
RU
Ruthann
1 year ago
I think "HELLO" will be printed only once, but I'm not entirely sure about the loop conditions.
RO
Rosio
1 year ago
I'm not sure about this one. The loop condition and the "continue" and "break" statements are making me a bit uncertain. I'll need to carefully step through the code to figure out the correct answer.
PO
Portia
1 year ago
This seems straightforward. The loop runs 10 times, but the "continue" statement skips the first 4 iterations, and the "break" statement exits the loop after the 5th iteration. So the answer is 2.
DE
Desire
1 year ago
Okay, I think I've got it. The loop runs 10 times, but the "continue" statement skips the first 4 iterations, and the "break" statement exits the loop after the 5th iteration. So "HELLO" will be printed 1 time.
WY
Wynell
1 year ago
This looks like a tricky one. I'll need to carefully trace the loop and conditional logic to figure out how many times "HELLO" will be printed.
LI
Lili
1 year ago
Hmm, I'm a bit confused by the loop condition. Does the "i < 5" check mean the loop will only run 5 times? I'll need to double-check that.
TH
Thurman
1 year ago
Hmm, this seems like a tricky one. I'll need to think through the different Outlook views and how they impact the alphabetical index.
PE
Pedro
1 year ago
I'm not totally sure about this, but I think unbuffered queries return the first data faster and use less memory. I'll give that a try and see.
BR
Brice
1 year ago
Okay, I've got a strategy. I'll start by identifying the correct statements about how big data could provide a small company with useful information and new opportunities.
VA
Val
1 year ago
Ah, the age-old battle of off-by-one errors. I bet the exam writer is having a good laugh at our expense right now.
RE
Reta
1 year ago
20? Are you kidding me? The loop runs from i=5 to i=10, and 'HELLO' is printed only once. This is clearly a joke answer. I'm going with B as the correct response.
SH
Shanice
1 year ago
This is a tricky one! The loop initializes i to some value, but the question doesn't specify what that value is. So, I'm not sure if the loop will even run. I'll go with C as the safest option.
GO
Goldie
1 year ago
Wait, what? The loop runs from i=5 to i=10, but the 'else' block with 'break' is executed as soon as i reaches 5. So, 'HELLO' is printed only once. I guess B is the right answer.
NA
Nan
1 year ago
You're right, it will only be printed once.
EL
Elina
1 year ago
Oh, I see. So the correct answer is B) 2
DE
Detra
1 year ago
No, it's actually B) 2
DO
Dorcas
1 year ago
I think the answer is A) 1
DE
Derick
1 year ago
No, it will only be printed once.
SO
Sonia
1 year ago
I think it will be printed twice.
EL
Eliseo
1 year ago
Hmm, let's see. The loop runs from i=5 to i=10, and 'HELLO' is printed in each iteration, so the answer must be 6. Looks like C is the correct choice.
FL
Florinda
1 year ago
Yes, the answer is 6.
AR
Arlyne
1 year ago
I agree, it should be 6 times.
HE
Heike
1 year ago
I think it will be printed 6 times.
SH
Shanice
2 years ago
I'm not sure, but I think the answer is A) 1 as well
EL
Elena
2 years ago
I agree with Providencia, because the loop will only print 'HELLO' once when i=5
PR
Providencia
2 years ago
I think the answer is A) 1