New Year Sale 2026! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

C++ Institute CPA-21-02 Exam - 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:

0/2000 characters
Sharita
2 months ago
Wait, are we sure there's no other error?
upvoted 0 times
...
Troy
2 months ago
Totally agree, that's a major error!
upvoted 0 times
...
Domitila
2 months ago
The variable 'i' is undeclared, that's a big issue.
upvoted 0 times
...
Shawn
3 months ago
Isn't 'c' supposed to be used in the switch?
upvoted 0 times
...
Darell
3 months ago
I think the switch statement is fine, just fix 'i'.
upvoted 0 times
...
Charlesetta
3 months ago
I feel like I’ve seen a similar question before, and it was about undeclared identifiers, so maybe that's the error here too.
upvoted 0 times
...
Malcom
3 months ago
I’m a bit confused; I thought 'continue' was only used in loops, so I don’t think that’s the problem here.
upvoted 0 times
...
Heidy
4 months ago
I remember something about switch statements, but I’m not sure if there’s an error with the case labels.
upvoted 0 times
...
Mammie
4 months ago
I think there’s an issue with the variable 'i' since it’s not declared anywhere in the program.
upvoted 0 times
...
Slyvia
4 months ago
I'm feeling pretty confident about this one. The error is clearly the use of the undeclared variable 'i' in the switch statement. I'll make a note to always double-check variable declarations when analyzing code.
upvoted 0 times
...
Miriam
4 months ago
Ah, I see the problem now. The variable 'i' is not defined, so the switch statement won't work as expected. I'll make sure to check for any undeclared variables when reviewing code on the exam.
upvoted 0 times
...
Alba
4 months ago
Okay, I think I've got it. The issue is that the variable 'i' is used in the switch statement, but it's never declared or initialized. That's gotta be the error they're looking for.
upvoted 0 times
...
Carma
5 months ago
Uh oh, I'm a bit confused here. The question mentions an error, but I'm not sure I see one right away. I'll have to double-check the syntax and variable declarations.
upvoted 0 times
...
Justine
5 months ago
Hmm, this looks tricky. I'll need to carefully read through the code and think about the use of the switch statement and the variable 'i'.
upvoted 0 times
...
Whitley
5 months ago
I think the error is in the line 'switch(i)' because 'i' is not declared anywhere in the program.
upvoted 0 times
...
Tawna
6 months ago
B) Use of undeclared identifier 'i'
upvoted 0 times
...
Galen
6 months 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
Alfred
5 months ago
B) Use of undeclared identifier 'i'
upvoted 0 times
...
Magda
5 months ago
A) No Error
upvoted 0 times
...
...
Maia
7 months 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
Jamie
5 months ago
A) No Error
upvoted 0 times
...
Tom
5 months ago
Yeah, definitely B. 'i' is nowhere to be found in the code.
upvoted 0 times
...
Evelynn
7 months ago
B) Use of undeclared identifier 'i'
upvoted 0 times
...
...

Save Cancel