C Pointers Test 11) In a structure, if a variable works as a pointer then from the given below operators which operator is used for accessing data of the structure using the variable pointer?
The correct option is (b). Explanation: For a structure, Arrow ( ->) is used for access the data using pointer variable and Dot(.) operator can be used for accessing the data using normal structure variable. 2) For the array element a[i][j][k][2], determine the equivalent pointer expression.
The correct option is (a). Explanation: For the array element a[i][j] the pointer expression is *(*(a+i)+j) For the array element a[i][j][k] the pointer expression is *(*(*(a+i)+j)+k) For the array element a[i][j][k][2] the pointer expression is *(*(*(*(a+i)+j)+k)+2) 3) Are the expression ++*ptr and *ptr++ are same?
The correct option is (b). Explanation: ++*ptr increments the value pointed by ptr and*ptr++ increments the pointer not the value. 4) Select the correct statement which is a combination of these two statements,
The correct option is (a). Explanation: The below code is a prototype of malloc() function, here ptr indicates the pointer. In below code, "*p" is a pointer of data type char and malloc() function is used for allocating the memory for char. 5) For the below mention C statement, what is your comment?
The correct option is (d). Explanation: The size of int and unsigned data type is same therefore there is no problem in a C statement: signed int *p=(int*)malloc(sizeof(unsigned int)); |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India