BlackFriday 2024! 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
4 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
4 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
3 months ago
No, I believe it will result in a compilation error.
upvoted 0 times
...
Lemuel
4 months ago
I think it will print '123'.
upvoted 0 times
...
...
Laticia
4 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
4 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
3 months ago
No, it will actually print '123'.
upvoted 0 times
...
Truman
4 months ago
I think it will print '021' as well.
upvoted 0 times
...
...
Stevie
5 months ago
I think it will print '132'.
upvoted 0 times
...
Broderick
5 months ago
I think it will print '021'.
upvoted 0 times
...
Sarah
5 months ago
I believe it will result in a compilation error.
upvoted 0 times
...
Tawna
5 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
4 months ago
Yes, the code will give a compilation error due to the use of the undeclared variable s4.
upvoted 0 times
...
Solange
4 months ago
I agree, the code will not compile because of the undeclared variable s4.
upvoted 0 times
...
Ines
4 months ago
You're right, the answer is B. Compilation error because of the undeclared variable s4.
upvoted 0 times
...
Bea
4 months ago
Yes, the code will give a compilation error due to the use of the undeclared variable s4.
upvoted 0 times
...
Tatum
5 months ago
I agree, the code will not compile because of the undeclared variable s4.
upvoted 0 times
...
...
Theron
5 months ago
I think it will print '123'.
upvoted 0 times
...

Save Cancel