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 8 Question 41 Discussion

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

Point out an error in the program.

#include

using namespace std;

int main()

{

const int x=1;

int const *y=&x;

cout<<*y;

return 0;

}

Show Suggested Answer Hide Answer
Suggested Answer: A

Contribute your Thoughts:

0/2000 characters
Blair
2 months ago
Definitely an error with pointer conversion.
upvoted 0 times
...
Lenna
2 months ago
I think it's a compilation error, right?
upvoted 0 times
...
Latrice
2 months ago
Looks like there's a const pointer issue.
upvoted 0 times
...
Janessa
3 months ago
No error, it should compile fine!
upvoted 0 times
...
Kris
3 months ago
Wait, is there really a problem with this code?
upvoted 0 times
...
Ressie
3 months ago
I feel like there’s definitely a compilation error here, but I need to double-check the pointer declarations to be certain.
upvoted 0 times
...
Carolynn
3 months ago
I'm leaning towards option C, but I can't recall if it's about the conversion from 'const int *' to 'int *const' or something else.
upvoted 0 times
...
Erinn
4 months ago
I remember a similar question where we had to deal with const pointers. I think it might be related to converting between const types.
upvoted 0 times
...
Claribel
4 months ago
I think there might be an issue with the pointer type, but I'm not entirely sure what the exact error is.
upvoted 0 times
...
Catrice
4 months ago
No problem, I've seen this type of question before. The error is in the declaration of `y` - it should be `int* const y = &x;` to match the `const int x`.
upvoted 0 times
...
Maia
4 months ago
I'm a bit confused by the pointer syntax here. I'll need to review my notes on const pointers to figure out the right way to declare `y`.
upvoted 0 times
...
Laurel
4 months ago
Ah, I see the problem now! The declaration of `y` is incorrect. It should be `int* const y = &x;` to match the `const int x`.
upvoted 0 times
...
Lura
5 months ago
Okay, let me see here... the issue seems to be with the pointer declaration. I'm not entirely sure, but I think it might be a problem with the const placement.
upvoted 0 times
...
Marjory
5 months ago
Hmm, this looks like a tricky one. I'll need to carefully read through the code and think about the pointer declarations.
upvoted 0 times
...
Eladia
7 months ago
This question is making my head spin! I'm just going to guess and hope for the best. Let's go with... B) Error: unknown pointer conversion. Why not, right?
upvoted 0 times
...
Noelia
7 months ago
Wait, is this a trick question? Surely there has to be a mistake somewhere. I'll play it safe and say D) Compilation error.
upvoted 0 times
...
Yoko
7 months ago
Hold on, didn't we learn about this in class? I think the correct answer is B) Error: unknown pointer conversion. I'll go with that.
upvoted 0 times
Cristal
5 months ago
Yeah, I remember that too. It's definitely an error with the pointer conversion.
upvoted 0 times
...
Alline
5 months ago
I think the error is B) Error: unknown pointer conversion.
upvoted 0 times
...
Bea
6 months ago
I think the correct answer is B) Error: unknown pointer conversion.
upvoted 0 times
...
...
Margurite
7 months ago
I believe there is a compilation error in the program.
upvoted 0 times
...
Glen
7 months ago
Hmm, I'm not sure about this one. Isn't there something about const pointers? I'll guess C) cannot convert from 'const int *' to 'int *const'.
upvoted 0 times
Therese
7 months ago
User2: C) cannot convert from 'const int *' to 'int *const'
upvoted 0 times
...
Johana
7 months ago
User1: B) Error: unknown pointer conversion
upvoted 0 times
...
...
Xenia
8 months ago
D) Compilation error
upvoted 0 times
...
Margo
8 months ago
This code looks fine to me. The output will be '1', so I'll go with A) No error.
upvoted 0 times
Noel
7 months ago
User 1
upvoted 0 times
...
Lajuana
7 months ago
User 2
upvoted 0 times
...
Twana
7 months ago
User 1
upvoted 0 times
...
...
Kayleigh
8 months ago
I think the error is in the pointer conversion.
upvoted 0 times
...
Gianna
8 months ago
B) Error: unknown pointer conversion
upvoted 0 times
...

Save Cancel