Cyber Monday 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 6 Question 94 Discussion

Actual exam question for C++ Institute's CPA exam
Question #: 94
Topic #: 6
[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:

Aide
3 months ago
Ooh, this is a good one. The output will be '132' because that's the order of the enum values we assigned.
upvoted 0 times
Simona
2 months ago
Great, I understand now. Thanks for explaining!
upvoted 0 times
...
Aileen
3 months ago
Yes, you're right. The output will be '132' in this case.
upvoted 0 times
...
Sharen
3 months ago
I think it will print '132' because that's the order of the enum values we assigned.
upvoted 0 times
...
...
Adell
4 months ago
Haha, I can totally see someone accidentally typing '123' and thinking it's the right answer. Nice try, tricky question!
upvoted 0 times
...
Tamie
4 months ago
Wait, why is there an s4 variable? That's not defined in the enum! This should throw a compilation error.
upvoted 0 times
Maybelle
2 months ago
So, the output will be a compilation error for sure.
upvoted 0 times
...
Hector
2 months ago
Yeah, the code won't compile because s4 is not part of the enum.
upvoted 0 times
...
Stephen
3 months ago
I think the correct answer is B) compilation error.
upvoted 0 times
...
Sueann
3 months ago
You're right, s4 is not defined in the enum. It will definitely throw a compilation error.
upvoted 0 times
...
...
Gregoria
4 months ago
I think it will print '132'.
upvoted 0 times
...
Val
4 months ago
I think it will print '021'.
upvoted 0 times
...
Whitney
4 months ago
I believe there will be a compilation error.
upvoted 0 times
...
Lea
4 months ago
I think it will print '123'.
upvoted 0 times
...
Truman
4 months ago
This is a simple enum example, the output should be '021' as the enum values are printed directly.
upvoted 0 times
Desmond
4 months ago
Yes, that's correct. It's a simple example of using enums in C++.
upvoted 0 times
...
Desmond
4 months ago
Oh, I see. So the enum values are printed directly.
upvoted 0 times
...
Desmond
4 months ago
It will print: '021'
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