BLACK FRIDAY SALE – Unlock Up to 25% OFF on All Exam Prep! - 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

Posted by Corazon on Jul 05, 2025 at 11:19 PM

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;

}

Suggested Answer: A

Get Premium CPA-21-02 Questions as Interactive Web-Based Practice Test or PDF Real Exam Format Detailed Explanations Instant Access Get Your Practice Test
31 comments · newest first
BL
Blair 11 months ago
Definitely an error with pointer conversion.
LE
Lenna 11 months ago
I think it's a compilation error, right?
LA
Latrice 12 months ago
Looks like there's a const pointer issue.
JA
Janessa 12 months ago
No error, it should compile fine!
KR
Kris 1 year ago
Wait, is there really a problem with this code?
RE
Ressie 1 year ago
I feel like there’s definitely a compilation error here, but I need to double-check the pointer declarations to be certain.
CA
Carolynn 1 year 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.
ER
Erinn 1 year 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.
CL
Claribel 1 year ago
I think there might be an issue with the pointer type, but I'm not entirely sure what the exact error is.
CA
Catrice 1 year 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`.
MA
Maia 1 year 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`.
LA
Laurel 1 year 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`.
LU
Lura 1 year 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.
MA
Marjory 1 year ago
Hmm, this looks like a tricky one. I'll need to carefully read through the code and think about the pointer declarations.
EL
Eladia 1 year 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?
NO
Noelia 1 year 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.
YO
Yoko 1 year 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.
CR
Cristal 1 year ago
↳ replying to Yoko
Yeah, I remember that too. It's definitely an error with the pointer conversion.
AL
Alline 1 year ago
↳ replying to Yoko
I think the error is B) Error: unknown pointer conversion.
BE
Bea 1 year ago
↳ replying to Yoko
I think the correct answer is B) Error: unknown pointer conversion.
MA
Margurite 1 year ago
I believe there is a compilation error in the program.
GL
Glen 1 year 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'.
TH
Therese 1 year ago
↳ replying to Glen
User2: C) cannot convert from 'const int *' to 'int *const'
JO
Johana 1 year ago
↳ replying to Glen
User1: B) Error: unknown pointer conversion
XE
Xenia 1 year ago
D) Compilation error
MA
Margo 1 year ago
This code looks fine to me. The output will be '1', so I'll go with A) No error.
NO
Noel 1 year ago
↳ replying to Margo
User 1
LA
Lajuana 1 year ago
↳ replying to Margo
User 2
TW
Twana 1 year ago
↳ replying to Margo
User 1
KA
Kayleigh 1 year ago
I think the error is in the pointer conversion.
GI
Gianna 1 year ago
B) Error: unknown pointer conversion
0/2000 characters

Save Cancel