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
28 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
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
2 days ago
User3: I think it will print: world
upvoted 0 times
...
Twila
9 days ago
User2: User1 is correct. It will print: Hello
upvoted 0 times
...
Dottie
14 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
13 days ago
User 3: And then the 'world' message will be printed right after it.
upvoted 0 times
...
Raelene
22 days ago
User 2: Correct, the preprocessor will include the 'Hello' message.
upvoted 0 times
...
Lemuel
1 months 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
16 days ago
Oh, I see. Thanks for clarifying!
upvoted 0 times
...
Davida
20 days ago
Actually, it will print: Hello
upvoted 0 times
...
Heike
22 days ago
No, it will print: Helloworld
upvoted 0 times
...
Lenita
26 days 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
1 months ago
I think it will print: Hello
upvoted 0 times
...
...
Charlette
2 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
az-700  pass4success  az-104  200-301  200-201  cissp  350-401  350-201  350-501  350-601  350-801  350-901  az-720  az-305  pl-300  

Warning: Cannot modify header information - headers already sent by (output started at /pass.php:70) in /pass.php on line 77