Which of the following is not a correct declaration statement in C++?

2018

Which of the following is not a correct declaration statement in C++?

  1. A.

    int *ptr=0, p;

  2. B.

    int p, *ptr = 0;

  3. C.

    int p; double *fp = &p;

  4. D.

    int *p, *q, r;

Attempted by 159 students.

Show answer & explanation

Correct answer: C

In C++, pointers require matching types for valid assignment. Option C incorrectly assigns an int address to a double pointer, violating type safety rules. Options A, B, and D follow correct syntax for valid declarations.

Explore the full course: Uppsc Polytechnic Lecturer 2025 Cs