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 Exam CPA-21-02 Topic 4 Question 19 Discussion

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

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;

}

Show Suggested Answer Hide Answer
Suggested Answer: A, B

Contribute your Thoughts:

Val
1 months 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.
upvoted 0 times
...
Reta
1 months 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.
upvoted 0 times
...
Shanice
1 months 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.
upvoted 0 times
...
Goldie
1 months 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.
upvoted 0 times
Nan
24 hours ago
You're right, it will only be printed once.
upvoted 0 times
...
Elina
3 days ago
Oh, I see. So the correct answer is B) 2
upvoted 0 times
...
Detra
4 days ago
No, it's actually B) 2
upvoted 0 times
...
Dorcas
9 days ago
I think the answer is A) 1
upvoted 0 times
...
Derick
13 days ago
No, it will only be printed once.
upvoted 0 times
...
Sonia
24 days ago
I think it will be printed twice.
upvoted 0 times
...
...
Eliseo
2 months 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.
upvoted 0 times
Florinda
12 days ago
Yes, the answer is 6.
upvoted 0 times
...
Arlyne
16 days ago
I agree, it should be 6 times.
upvoted 0 times
...
Heike
1 months ago
I think it will be printed 6 times.
upvoted 0 times
...
...
Shanice
2 months ago
I'm not sure, but I think the answer is A) 1 as well
upvoted 0 times
...
Elena
2 months ago
I agree with Providencia, because the loop will only print 'HELLO' once when i=5
upvoted 0 times
...
Providencia
2 months ago
I think the answer is A) 1
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