Knowee
Questions
Features
Study Tools

Comment on the following pointer declaration.int *ptr, p; ptr is a pointer to integer, p is notptr and p, both are pointers to integerptr is a pointer to integer, p may or may not beptr and p both are not pointers to integer

Question

Comment on the following pointer declaration.int *ptr, p; ptr is a pointer to integer, p is notptr and p, both are pointers to integerptr is a pointer to integer, p may or may not beptr and p both are not pointers to integer

🧐 Not the exact question you are looking for?Go ask a question

Solution

The correct statement is "ptr is a pointer to integer, p is not".

In the declaration int *ptr, p;, ptr is declared as a pointer to an integer because of the asterisk (*) before its name. This means that ptr can hold the address of an integer variable.

On the other hand, p is just a regular integer variable. The asterisk () does not apply to p because in C and C++, the asterisk () applies to the variable name it is directly attached to, not the entire declaration. Therefore, p is not a pointer, it's a regular integer variable that can hold an integer value.

This problem has been solved

Similar Questions

Comment on the following pointer declaration.int *ptr, p;

What is the correct syntax to declare a pointer in C++?int &ptr;int ptr*;int *ptr;int ptr&;

ct the correct answerWhich of the following is the correct way to declare a pointer to an integer in C?Optionsinteger *ptr;ptr *int;int *ptr;point int *ptr;

In C, what is the result of declaring a pointer as int *ptr; without initialization?Marks : 1Negative Marks : 0Answer hereThe value of the variableptr points to a specific known memory locationptr contains a garbage value as its addressptr points to the memory location 0

In C, what is the result of declaring a pointer as int *ptr; without initialization?

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.