int main
{
typedef char ((arrfptr[4]))[20];
arrfptr y;
return 0;
}
Example
- 'x' is an array of three pointers
- 'x' is an array of three function pointers
- 'x' is a pointer
- Error in 'x' declaration
The correct option is (b).
Explanation:
The statement typedef char (*(*arrfptr[4])())[20]; means arfptr is an array of 3 function pointer which will return an array of 20 dimension whose data type is char.
Therefore 'x' is an array of three function pointers.
## 17) The return keyword is used for transfer control from a function back to the calling function.
The correct option is (a).
Explanation:
In C, the return function stops the execution of function and returns the control with value to the calling function. Execution is begins in calling function by instantly following the call.
## 18) What will be the output of the below program?
include<stdio.h>
main
{
struct { int y;} var = {4}, *a = &var;
printf("%d %d %d",var.y,a->y,(*a).y);
}
Example
- 4 4 garbage value
- 4 4 0
- 4 4 4
- Compile error
The correct option is (c).
Explanation:
The two possible methods of accessing structure elements using pointer is by using * or -> (arrow operator).
Therefore the output of a program is 4 4 4.
## 19) What will be the output of the below program?
include<stdio.h>
main
{
int a[3] = {1,,2};
printf("%d", a[a[0]]);
}
Example
- Compile error
The correct option is (d).
Explanation:
In the program invalid syntax is used for initializing the array. Therefore compile error occurs in the output of a program.
## 20) Find out whether both the loops in a program prints the correct string length?
include<stdio.h>
main
{
int j;
char s = "javaLogic Practice";
for(j=0; s[j]; ++j);
printf("%d \n", j);
j=0;
while(s[j++]);
printf("%d ", j);
}
Example
- Yes, both the loops prints the correct string length
- Only while loop prints the correct string length
- Only for loop prints the correct string length
- Compile error in the program
The correct option is (c).
Explanation:
Output: 10
11
Example
In a while loop, the incorrect length of the string is displayed as the variable 'i' is incremented after checking for '\0', resulting in a length that is one more than the actual length of the string.
Thus, only the for loop accurately displays the length of the string.