Short answer type Questions on Pointer
1. What is a pointer?
A pointer is a dynamic variable that stores address of a data value in a program.
2. How is a pointer declared in a C program?
syntax: datatype * pointer name;
Example: int *p, x=2;
3. Name the operators used in pointers?
* and & operators
4. How is a pointer initialized . give an ex.
Initializing a pointer means storing the address of the data variable in to a pointer.
Ex: p1=&x;
5. What is meant by a pointer to an array?
A pointer to an array stores address of the 1st data element of the array.
Ex: int *p, a[4];
p=a;
or
p=&a[0];
6. If ptr is a pointer to an integer what is the meaning of an expression ptr++; ?
ptr++; will increment the pointer and will make the pointer store address of next data element in the array.
7. What is meant by an array of pointers?
An array of pointer means a pointer array where every individual data is a pointer
variable that holds an address.
Ex: int *p[10], a[10], b[10], c[10];
p[0]=&a[0];
p[1]=&b[0];
p[2]=&c[0];
8. Is it possible to add two pointers?
no.
Thanks
Mukesh Rajput
Post A Comment:
0 comments: