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 3 Question 43 Discussion

Actual exam question for C++ Institute's CPA-21-02 exam
Question #: 43
Topic #: 3
[All CPA-21-02 Questions]

If there is one, point out an error in the program

#include

using namespace std;

int main()

{

int c = 'a';

switch(i)

{

case '2':

cout<<"OK";

case '1':

cout<<"Error";

default:

break;

}

return 0;

}

Show Suggested Answer Hide Answer
Suggested Answer: B

Contribute your Thoughts:

Tawna
2 days ago
B) Use of undeclared identifier 'i'
upvoted 0 times
...
Galen
3 days ago
I'd say it's D. The 'break' statement inside the 'default' case is not necessary and could be considered an illegal use of it.
upvoted 0 times
...
Maia
16 days ago
Definitely B. The variable 'i' is not declared anywhere in the code, so it's a clear case of using an undeclared identifier.
upvoted 0 times
Evelynn
11 days ago
B) Use of undeclared identifier 'i'
upvoted 0 times
...
...

Save Cancel