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 Topic 8 Question 90 Discussion

Actual exam question for C++ Institute's CPA - C++ Certified Associate Programmer exam
Question #: 90
Topic #: 8
[All CPA - C++ Certified Associate Programmer Questions]

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

#include

using namespace std;

int main (int argc, const char * argv[])

{

enum state { ok, error, warning};

enum state s1, s2, s3;

s1 = ok;

s2 = warning;

s3 = error;

s4 = ok;

cout << s1<< s2<< s3;

return 0;

}

Show Suggested Answer Hide Answer
Suggested Answer: B

Contribute your Thoughts:

Phuong
1 months ago
Haha, this code is like a bad joke. Of course it's going to be a compilation error. Who writes code like that? B all the way!
upvoted 0 times
...
Hayley
1 months ago
Wow, this is a tricky one! I'm going to have to go with B. Compilation error. Can't use an undeclared variable like that and expect it to work.
upvoted 0 times
Candida
25 days ago
User2: No, I believe it will result in a compilation error.
upvoted 0 times
...
Lemuel
30 days ago
User1: I think it will print '123'.
upvoted 0 times
...
...
Laticia
2 months ago
I'm going with D. It will print '132'. The enum values are 0, 1, and 2, and we're printing them in the order s1, s2, s3, which should give us '132'.
upvoted 0 times
...
Bernardine
2 months ago
My guess is C. It will print '021'. The enum values are 0, 1, and 2, so when we print them, we should get that output.
upvoted 0 times
Truman
23 days ago
No, it will actually print '123'.
upvoted 0 times
...
Truman
1 months ago
I think it will print '021' as well.
upvoted 0 times
...
...
Stevie
2 months ago
I think it will print '132'.
upvoted 0 times
...
Broderick
2 months ago
I think it will print '021'.
upvoted 0 times
...
Sarah
2 months ago
I believe it will result in a compilation error.
upvoted 0 times
...
Tawna
2 months ago
Hmm, I think the answer is B. Compilation error. The code tries to use an undeclared variable s4, which should result in a compilation error.
upvoted 0 times
Mona
1 months ago
Yes, the code will give a compilation error due to the use of the undeclared variable s4.
upvoted 0 times
...
Solange
2 months ago
I agree, the code will not compile because of the undeclared variable s4.
upvoted 0 times
...
Ines
2 months ago
You're right, the answer is B. Compilation error because of the undeclared variable s4.
upvoted 0 times
...
Bea
2 months ago
Yes, the code will give a compilation error due to the use of the undeclared variable s4.
upvoted 0 times
...
Tatum
2 months ago
I agree, the code will not compile because of the undeclared variable s4.
upvoted 0 times
...
...
Theron
2 months ago
I think it will print '123'.
upvoted 0 times
...

Save Cancel