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 5 Question 20 Discussion

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

What will happen when you attempt to compile and run the following code?

#include

using namespace std;

#define A 1

int main()

{

#if A

cout<<"Hello";

#endif

cout<<"world";

return 0;

}

Show Suggested Answer Hide Answer
Suggested Answer: C

Contribute your Thoughts:

Mattie
1 months ago
The correct answer is definitely B) It will print: Hello. I mean, come on, it's a simple preprocessor directive. How could anyone get that wrong?
upvoted 0 times
...
Stefan
1 months ago
Hmm, I'm not sure. Maybe D) It will print: 0? That would be a pretty funny outcome if the code just returned 0 instead of actually printing anything.
upvoted 0 times
Martina
15 days ago
User3: I think it will print: world
upvoted 0 times
...
Twila
22 days ago
User2: User1 is correct. It will print: Hello
upvoted 0 times
...
Dottie
27 days ago
User1: It will print: Hello
upvoted 0 times
...
...
Ashanti
2 months ago
I think the answer is A) It will print: Helloworld. The preprocessor will include the 'Hello' message, and then the 'world' message will be printed right after it.
upvoted 0 times
Gerry
26 days ago
User 3: And then the 'world' message will be printed right after it.
upvoted 0 times
...
Raelene
1 months ago
User 2: Correct, the preprocessor will include the 'Hello' message.
upvoted 0 times
...
Lemuel
2 months ago
User 1: I think the answer is A) It will print: Helloworld.
upvoted 0 times
...
...
Paz
3 months ago
I think the answer is C because the preprocessor directive #if A evaluates to true since A is defined as 1.
upvoted 0 times
...
Antione
3 months ago
The answer is B) It will print: Hello. The #if preprocessor directive will evaluate A to be true, and so the 'Hello' message will be printed, followed by the 'world' message.
upvoted 0 times
Carolynn
29 days ago
Oh, I see. Thanks for clarifying!
upvoted 0 times
...
Davida
1 months ago
Actually, it will print: Hello
upvoted 0 times
...
Heike
1 months ago
No, it will print: Helloworld
upvoted 0 times
...
Lenita
1 months ago
Yes, because the #if directive will evaluate A to be true
upvoted 0 times
...
Lenita
1 months ago
I think it will print: Hello
upvoted 0 times
...
Chaya
2 months ago
I think it will print: Hello
upvoted 0 times
...
...
Charlette
3 months ago
I believe the answer is B.
upvoted 0 times
...
Martha
3 months ago
I think the answer is A.
upvoted 0 times
...

Save Cancel