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 exam
Question #: 90
Topic #: 8
[All CPA 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 years 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 years 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
1 years ago
No, I believe it will result in a compilation error.
upvoted 0 times
...
Lemuel
1 years ago
I think it will print '123'.
upvoted 0 times
...
...
Laticia
1 years 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
1 years 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
1 years ago
No, it will actually print '123'.
upvoted 0 times
...
Truman
1 years ago
I think it will print '021' as well.
upvoted 0 times
...
...
Stevie
1 years ago
I think it will print '132'.
upvoted 0 times
...
Broderick
1 years ago
I think it will print '021'.
upvoted 0 times
...
Sarah
1 years ago
I believe it will result in a compilation error.
upvoted 0 times
...
Tawna
1 years 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 years ago
Yes, the code will give a compilation error due to the use of the undeclared variable s4.
upvoted 0 times
...
Solange
1 years ago
I agree, the code will not compile because of the undeclared variable s4.
upvoted 0 times
...
Ines
1 years ago
You're right, the answer is B. Compilation error because of the undeclared variable s4.
upvoted 0 times
...
Bea
1 years ago
Yes, the code will give a compilation error due to the use of the undeclared variable s4.
upvoted 0 times
...
Tatum
1 years ago
I agree, the code will not compile because of the undeclared variable s4.
upvoted 0 times
...
...
Theron
1 years ago
I think it will print '123'.
upvoted 0 times
...

Save Cancel