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 CPA-21-02 Exam - Topic 8 Question 32 Discussion

How many times will the program print "HELLO" ?#include using namespace std;int main(){cout
B) 32769
A) 65536
C) 1
D) Till stack overflows

C++ Institute CPA-21-02 Exam - Topic 8 Question 32 Discussion

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

How many times will the program print "HELLO" ?

#include

using namespace std;

int main()

{

cout<<"HELLO";

main();

return 0;

}

Show Suggested Answer Hide Answer
Suggested Answer: B

Contribute your Thoughts:

0/2000 characters
Mariko
8 months ago
32769 seems way off, it's gotta be D.
upvoted 0 times
...
Broderick
9 months ago
I thought it would just print once, but I guess not!
upvoted 0 times
...
Pamella
9 months ago
Wait, how does it even know when to stop?
upvoted 0 times
...
Derrick
9 months ago
Definitely D, no doubt about it!
upvoted 0 times
...
Mollie
9 months ago
It'll print "HELLO" until the stack overflows.
upvoted 0 times
...
Shanda
10 months ago
I feel like it just prints "HELLO" once and then exits, but that doesn't seem right. I might be overthinking it.
upvoted 0 times
...
Major
10 months ago
This kind of question reminds me of a practice one where we had to calculate the depth of recursion. I think it could be a huge number like A or B, but I'm leaning towards D.
upvoted 0 times
...
Lottie
10 months ago
I remember something about recursion limits, but I'm not sure how many times it actually prints "HELLO" before that happens.
upvoted 0 times
...
Tomas
10 months ago
I think the program will keep calling main() recursively until the stack overflows, so it might be D.
upvoted 0 times
...
Brianne
10 months ago
I'm pretty confident the answer is D. Recursively calling main() like that will just keep going until the system runs out of memory and crashes.
upvoted 0 times
...
Tracey
10 months ago
Okay, I think I've got this. The program will keep printing "HELLO" until the stack overflows, so the answer is D.
upvoted 0 times
...
Chantay
10 months ago
Hmm, I'm a bit confused by this. Calling main() inside main() seems like it could cause an infinite loop, but I'm not sure exactly how that would play out.
upvoted 0 times
...
Erinn
10 months ago
This looks like a tricky one! I'll need to think it through carefully to avoid a silly mistake.
upvoted 0 times
...
Chandra
1 year ago
Hmm, I'm not too sure about this one. Maybe I should just ask the professor for the answer. Or maybe I can bribe the exam proctor? Just kidding, I'll go with option D.
upvoted 0 times
Rosann
1 year ago
I'm going with option D, till stack overflows.
upvoted 0 times
...
Gilma
1 year ago
I believe it will print 'HELLO' till the stack overflows.
upvoted 0 times
...
Rosann
1 year ago
Yes, I agree. It will keep printing 'HELLO' until the stack overflows.
upvoted 0 times
...
Veronika
1 year ago
I believe it will print 'HELLO' until the stack overflows as well.
upvoted 0 times
...
Leota
1 year ago
I think it will print 'HELLO' till the stack overflows.
upvoted 0 times
...
Theron
1 year ago
I think it will print 'HELLO' until the stack overflows.
upvoted 0 times
...
...
Mabel
1 year ago
Haha, this is a classic stack overflow question. The program will just keep printing 'HELLO' until it crashes the system. Option D all the way!
upvoted 0 times
Osvaldo
1 year ago
D) Till stack overflows
upvoted 0 times
...
Rosamond
1 year ago
Haha, this is a classic stack overflow question. The program will just keep printing 'HELLO' until it crashes the system. Option D all the way!
upvoted 0 times
...
Suzi
1 year ago
D) Till stack overflows
upvoted 0 times
...
Dortha
1 year ago
C) 1
upvoted 0 times
...
Billi
1 year ago
B) 32769
upvoted 0 times
...
Wilda
1 year ago
A) 65536
upvoted 0 times
...
Glynda
1 year ago
Definitely, option D is the correct choice.
upvoted 0 times
...
Vilma
1 year ago
You're right, it's a classic stack overflow scenario.
upvoted 0 times
...
Xuan
1 year ago
No way, it will print 'HELLO' till the stack overflows.
upvoted 0 times
...
Alison
1 year ago
I think it will print 'HELLO' 32769 times.
upvoted 0 times
...
...
Raina
1 year ago
I am not sure, but I think it will print 'HELLO' 65536 times.
upvoted 0 times
...
Julianna
1 year ago
I believe it will print 'HELLO' till stack overflows.
upvoted 0 times
...
Zana
1 year ago
I think the answer is B. The program will keep printing 'HELLO' until it hits the maximum signed integer value, which is 32769.
upvoted 0 times
Florinda
1 year ago
I think the answer is B. The program will keep printing 'HELLO' until it hits the maximum signed integer value, which is 32769.
upvoted 0 times
...
Catina
1 year ago
D) Till stack overflows
upvoted 0 times
...
Jacinta
1 year ago
C) 1
upvoted 0 times
...
Jerilyn
1 year ago
B) 32769
upvoted 0 times
...
Bobbye
1 year ago
A) 65536
upvoted 0 times
...
...
Elise
1 year ago
This is an infinite recursion problem! The program will keep calling `main()` until the stack overflows. I'm going with option D.
upvoted 0 times
Joye
1 year ago
Yes, that's the correct answer.
upvoted 0 times
...
Ivan
1 year ago
So, the correct option is D) Till stack overflows.
upvoted 0 times
...
Jospeh
1 year ago
I agree, the program will keep calling main() indefinitely.
upvoted 0 times
...
Verlene
1 year ago
I think it will print 'HELLO' till the stack overflows.
upvoted 0 times
...
...
Erin
1 year ago
I think it will print 'HELLO' 32769 times.
upvoted 0 times
...

Save Cancel