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
13 days 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
15 days 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
...
Ashanti
1 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
Raelene
7 days ago
User 2: Correct, the preprocessor will include the 'Hello' message.
upvoted 0 times
...
Lemuel
23 days ago
User 1: I think the answer is A) It will print: Helloworld.
upvoted 0 times
...
...
Paz
2 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
2 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
22 hours ago
Oh, I see. Thanks for clarifying!
upvoted 0 times
...
Davida
5 days ago
Actually, it will print: Hello
upvoted 0 times
...
Heike
7 days ago
No, it will print: Helloworld
upvoted 0 times
...
Lenita
11 days ago
Yes, because the #if directive will evaluate A to be true
upvoted 0 times
...
Lenita
16 days ago
I think it will print: Hello
upvoted 0 times
...
Chaya
19 days ago
I think it will print: Hello
upvoted 0 times
...
...
Charlette
2 months ago
I believe the answer is B.
upvoted 0 times
...
Martha
2 months ago
I think the answer is A.
upvoted 0 times
...

Save Cancel