How many times will the program print "HELLO" ?
#include
using namespace std;
int main()
{
cout<<"HELLO";
main();
return 0;
}
Suggested Answer: 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
45 comments · newest first
MA
Mariko
11 months ago
32769 seems way off, it's gotta be D.
BR
Broderick
11 months ago
I thought it would just print once, but I guess not!
PA
Pamella
11 months ago
Wait, how does it even know when to stop?
DE
Derrick
11 months ago
Definitely D, no doubt about it!
MO
Mollie
11 months ago
It'll print "HELLO" until the stack overflows.
SH
Shanda
12 months ago
I feel like it just prints "HELLO" once and then exits, but that doesn't seem right. I might be overthinking it.
MA
Major
12 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.
LO
Lottie
12 months ago
I remember something about recursion limits, but I'm not sure how many times it actually prints "HELLO" before that happens.
TO
Tomas
1 year ago
I think the program will keep calling main() recursively until the stack overflows, so it might be D.
BR
Brianne
1 year 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.
TR
Tracey
1 year ago
Okay, I think I've got this. The program will keep printing "HELLO" until the stack overflows, so the answer is D.
CH
Chantay
1 year 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.
ER
Erinn
1 year ago
This looks like a tricky one! I'll need to think it through carefully to avoid a silly mistake.
CH
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.
RO
Rosann
1 year ago
I'm going with option D, till stack overflows.
GI
Gilma
1 year ago
I believe it will print 'HELLO' till the stack overflows.
RO
Rosann
1 year ago
Yes, I agree. It will keep printing 'HELLO' until the stack overflows.
VE
Veronika
1 year ago
I believe it will print 'HELLO' until the stack overflows as well.
LE
Leota
1 year ago
I think it will print 'HELLO' till the stack overflows.
TH
Theron
1 year ago
I think it will print 'HELLO' until the stack overflows.
MA
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!
OS
Osvaldo
1 year ago
D) Till stack overflows
RO
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!
SU
Suzi
1 year ago
D) Till stack overflows
DO
Dortha
1 year ago
C) 1
BI
Billi
1 year ago
B) 32769
WI
Wilda
1 year ago
A) 65536
GL
Glynda
1 year ago
Definitely, option D is the correct choice.
VI
Vilma
1 year ago
You're right, it's a classic stack overflow scenario.
XU
Xuan
1 year ago
No way, it will print 'HELLO' till the stack overflows.
AL
Alison
1 year ago
I think it will print 'HELLO' 32769 times.
RA
Raina
1 year ago
I am not sure, but I think it will print 'HELLO' 65536 times.
JU
Julianna
2 years ago
I believe it will print 'HELLO' till stack overflows.
ZA
Zana
2 years ago
I think the answer is B. The program will keep printing 'HELLO' until it hits the maximum signed integer value, which is 32769.
FL
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.
CA
Catina
1 year ago
D) Till stack overflows
JA
Jacinta
1 year ago
C) 1
JE
Jerilyn
1 year ago
B) 32769
BO
Bobbye
1 year ago
A) 65536
EL
Elise
2 years ago
This is an infinite recursion problem! The program will keep calling `main()` until the stack overflows. I'm going with option D.
JO
Joye
1 year ago
Yes, that's the correct answer.
IV
Ivan
1 year ago
So, the correct option is D) Till stack overflows.
JO
Jospeh
1 year ago
I agree, the program will keep calling main() indefinitely.
VE
Verlene
1 year ago
I think it will print 'HELLO' till the stack overflows.
ER
Erin
2 years ago
I think it will print 'HELLO' 32769 times.