- In the following code what is ‘C’?
typedef char* charp;
const charp C;
a. C is a constant.
b. C is a character constant.
c. C is character type.
d. None of the above.
Answer : a
- The size of a void pointer in 16-bit system is __?
a. 1 Byte
b. 2 Bytes
c. 4 Bytes
d. 8 Bytes
Answer : b
- Which of the following does not initialize ptr to null
(assuming variable declaration of ‘var’ as int var=0)?
a. int *p = &var – &var;
b. int *p = var – var;
c. int *p = &var;
d. int *ptr=NULL;
Answer : c
- What is (void*)0?
a. Representation of void pointer
b. Representation of null pointer
c. Compilation error
d. None of them
Answer : b
- What is the output of following program?
#include<stdio.h>
int main()
{
int *ptr, var=5;
ptr = &var;
*ptr += 1;
printf(“%d, %d”, *ptr, var);
return 0;
}
a. 5, 5
b. 6, 5
c. 5, 6
d. 6, 6
Answer : d
- What the following, instruction tells?
const int *ptr;
a. We cannot change the pointer ptr itself.
b. We cannot change the value pointed by ptr.
c. Both (a) and (b).
d. We can change the pointer as well as the value pointed by it.
Answer : b
- What does the following declaration mean?
int (*ptr)[10];
a. ptr is 1-D array of size 10, of pointers to integers.
b. ptr is a pointer to a 10 elements integer array.
c. The same as int *ptr[10]
d. None of these.
Answer : b
C MCQ Set-19 Explanation
- What will be the output of the following program?
#include<stdio.h>
int main()
{
int var = 5;
void ptr = &var; printf(“%d\n”, (int)ptr);
return 0;
}
a. 5
b. Runtime Error
c. Compilation Error
d. Undefined behavior
Answer : c
C MCQ Set-19 Explanation
- What will be the output of the following program code?
#include<stdio.h>
int main()
{
int a = 15;
void *ptr = &a;
printf(“%f\n”, *(float *)ptr);
return 0;
}
a. 65624
b. 0.000000
c. 15
d. Error
Answer : b
- What will be the output of the following code?
#include<stdio.h>
int main()
{
int i = 5;
void *ptr = &i;
printf(“%d\n”, *(int *)ptr);
return 0;
}
a. 5
b. Garbage value
c. Compilation Error
d. None of these.
Answer : a