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
19 days 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
22 days 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
23 days 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
24 days 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
Sonia
9 days ago
I think it will be printed twice.
upvoted 0 times
...
...
Eliseo
1 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
Arlyne
23 hours ago
I agree, it should be 6 times.
upvoted 0 times
...
Heike
20 days 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