Which of the following operations on pointers would never work out? (i) Pointer variables can be compared provided both variables point to objects of the same data type (ii) Addition of two pointers (iii) Division of a pointer with a constant (iv) Multiplication of a pointer with a constant
Which of the following operations on pointers would never work out? (i) Pointer variables can be compared provided both variables point to objects of the same data type (ii) Addition of two pointers (iii) Division of a pointer with a constant (iv) Multiplication of a pointer with a constant Correct Answer (ii), (iii) and (iv)
Pointer:
A pointer is a variable whose value is the address of another variable, i.e., direct address of the memory location. Like any variable or constant, you must declare a pointer before using it to store any variable address.
The major advantages of pointers are:
(i) It allows the management of structures that are allocated memory dynamically.
(ii) It allows the passing of arrays and strings to functions more efficiently.
(iii) It makes it possible to pass the address of structure instead of the entire structure to the functions.
(iv) It makes it possible to return more than one value from the function.
(v) It reduces the length of the program.
(vi) To pass array no need to pass the total array pass only 1st element address. It will reduce the length of the program and it will reduce the complexity of the program.
Hence, only statement (i) is correct.