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

Posted by Casie on Dec 09, 2024 at 02:12 AM

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
↳ replying to Chandra
I'm going with option D, till stack overflows.
GI
Gilma 1 year ago
↳ replying to Chandra
I believe it will print 'HELLO' till the stack overflows.
RO
Rosann 1 year ago
↳ replying to Chandra
Yes, I agree. It will keep printing 'HELLO' until the stack overflows.
VE
Veronika 1 year ago
↳ replying to Chandra
I believe it will print 'HELLO' until the stack overflows as well.
LE
Leota 1 year ago
↳ replying to Chandra
I think it will print 'HELLO' till the stack overflows.
TH
Theron 1 year ago
↳ replying to Chandra
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
↳ replying to Mabel
D) Till stack overflows
RO
Rosamond 1 year ago
↳ replying to Mabel
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
↳ replying to Mabel
D) Till stack overflows
DO
Dortha 1 year ago
↳ replying to Mabel
C) 1
BI
Billi 1 year ago
↳ replying to Mabel
B) 32769
WI
Wilda 1 year ago
↳ replying to Mabel
A) 65536
GL
Glynda 1 year ago
↳ replying to Mabel
Definitely, option D is the correct choice.
VI
Vilma 1 year ago
↳ replying to Mabel
You're right, it's a classic stack overflow scenario.
XU
Xuan 1 year ago
↳ replying to Mabel
No way, it will print 'HELLO' till the stack overflows.
AL
Alison 1 year ago
↳ replying to Mabel
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
↳ replying to Zana
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
↳ replying to Zana
D) Till stack overflows
JA
Jacinta 1 year ago
↳ replying to Zana
C) 1
JE
Jerilyn 1 year ago
↳ replying to Zana
B) 32769
BO
Bobbye 1 year ago
↳ replying to Zana
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
↳ replying to Elise
Yes, that's the correct answer.
IV
Ivan 1 year ago
↳ replying to Elise
So, the correct option is D) Till stack overflows.
JO
Jospeh 1 year ago
↳ replying to Elise
I agree, the program will keep calling main() indefinitely.
VE
Verlene 1 year ago
↳ replying to Elise
I think it will print 'HELLO' till the stack overflows.
ER
Erin 2 years ago
I think it will print 'HELLO' 32769 times.
0/2000 characters

Save Cancel