MCQOPTIONS
Saved Bookmarks
This section includes 55 Mcqs, each offering curated multiple-choice questions to sharpen your C Programming knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
Is the following declaration correct?; |
| A. | Yes |
| B. | No |
| Answer» B. No | |
| 2. |
Are the following declarations same? |
| A. | Yes |
| B. | No |
| Answer» C. | |
| 3. |
It is not necessary to typecast the address returned by . |
| A. | True |
| B. | False |
| Answer» C. | |
| 4. |
Is the following declaration correct? |
| A. | Yes |
| B. | No |
| Answer» C. | |
| 5. |
Does the data type of all elements in the will be same. |
| A. | True |
| B. | False |
| Answer» C. | |
| 6. |
What will be the output of the program?_x000D_ #include_x000D_ typedef void v;_x000D_ typedef int i;_x000D_ _x000D_ int main()_x000D_ {_x000D_ v fun(i, i);_x000D_ fun(2, 3);_x000D_ return 0;_x000D_ }_x000D_ v fun(i a, i b)_x000D_ {_x000D_ i s=2;_x000D_ float i;_x000D_ printf("%d,", sizeof(i));_x000D_ printf(" %d", a*b*s);_x000D_ } |
| A. | 2, 8 |
| B. | 4, 8 |
| C. | 2, 4 |
| D. | 4, 12 |
| Answer» E. | |
| 7. |
What will be the output of the program?_x000D_ #include_x000D_ _x000D_ int main()_x000D_ {_x000D_ struct s1_x000D_ {_x000D_ char *z;_x000D_ int i;_x000D_ struct s1 *p;_x000D_ };_x000D_ static struct s1 a[] = {{"Nagpur", 1, a+1} , {"Chennai", 2, a+2} , _x000D_ {"Bangalore", 3, a} };_x000D_ _x000D_ struct s1 *ptr = a;_x000D_ printf("%s,", ++(ptr->z));_x000D_ printf(" %s,", a[(++ptr)->i].z);_x000D_ printf(" %s", a[--(ptr->p->i)].z);_x000D_ return 0;_x000D_ } |
| A. | Nagpur, Chennai, Bangalore |
| B. | agpur, hennai, angalore |
| C. | agpur, Chennai, angalore |
| D. | agpur, Bangalore, Bangalore |
| Answer» E. | |
| 8. |
Declare the following statement?_x000D_ "An array of three pointers to chars". |
| A. | char *ptr[3](); |
| B. | char *ptr[3]; |
| C. | char (*ptr[3])(); |
| D. | char **ptr[3]; |
| Answer» C. char (*ptr[3])(); | |
| 9. |
Declare the following statement?_x000D_ "A pointer to an array of three chars". |
| A. | char *ptr[3](); |
| B. | char (*ptr)*[3]; |
| C. | char (*ptr[3])(); |
| D. | char (*ptr)[3]; |
| Answer» E. | |
| 10. |
What will be the output of the program?_x000D_ #include_x000D_ _x000D_ int main()_x000D_ {_x000D_ char huge *near *far *ptr1;_x000D_ char near *far *huge *ptr2;_x000D_ char far *huge *near *ptr3;_x000D_ printf("%d, %d, %d\n", sizeof(**ptr1), sizeof(ptr2), sizeof(*ptr3));_x000D_ return 0;_x000D_ } |
| A. | 4, 4, 4 |
| B. | 2, 2, 2 |
| C. | 2, 8, 4 |
| D. | 2, 4, 8 |
| Answer» B. 2, 2, 2 | |
| 11. |
What will be the output of the program?_x000D_ #include_x000D_ _x000D_ int main()_x000D_ {_x000D_ char huge *near *far *ptr1;_x000D_ char near *far *huge *ptr2;_x000D_ char far *huge *near *ptr3;_x000D_ printf("%d, %d, %d\n", sizeof(ptr1), sizeof(*ptr2), sizeof(**ptr3));_x000D_ return 0;_x000D_ } |
| A. | 4, 4, 4 |
| B. | 2, 4, 4 |
| C. | 4, 4, 2 |
| D. | 2, 4, 8 |
| Answer» B. 2, 4, 4 | |
| 12. |
What will be the output of the program?_x000D_ #include_x000D_ _x000D_ int main()_x000D_ {_x000D_ char huge *near *ptr1;_x000D_ char huge *far *ptr2;_x000D_ char huge *huge *ptr3;_x000D_ printf("%d, %d, %d\n", sizeof(ptr1), sizeof(ptr2), sizeof(ptr3));_x000D_ return 0;_x000D_ } |
| A. | 4, 4, 8 |
| B. | 2, 4, 4 |
| C. | 4, 4, 2 |
| D. | 2, 4, 8 |
| Answer» C. 4, 4, 2 | |
| 13. |
What will be the output of the program?_x000D_ #include_x000D_ _x000D_ int main()_x000D_ {_x000D_ char far *near *ptr1;_x000D_ char far *far *ptr2;_x000D_ char far *huge *ptr3;_x000D_ printf("%d, %d, %d\n", sizeof(ptr1), sizeof(ptr2), sizeof(ptr3));_x000D_ return 0;_x000D_ } |
| A. | 4, 4, 8 |
| B. | 4, 4, 4 |
| C. | 2, 4, 4 |
| D. | 2, 4, 8 |
| Answer» D. 2, 4, 8 | |
| 14. |
What do the following declaration signify?_x000D_ int *f(); |
| A. | f is a pointer variable of function type. |
| B. | f is a function returning pointer to an int. |
| C. | f is a function pointer. |
| D. | f is a simple declaration of pointer variable. |
| Answer» C. f is a function pointer. | |
| 15. |
Declare the following statement?''An array of three pointers to chars''. |
| A. | char *ptr[3](); |
| B. | char *ptr[3]; |
| C. | char (*ptr[3])(); |
| D. | char **ptr[3]; |
| Answer» C. char (*ptr[3])(); | |
| 16. |
Declare the following statement?''A pointer to a function which receives nothing and returns nothing''. |
| A. | void *(ptr)*int; |
| B. | void *(*ptr)() |
| C. | void *(*ptr)(*) |
| D. | void (*ptr)() |
| Answer» E. | |
| 17. |
Declare the following statement?''A pointer to a function which receives an int pointer and returns float pointer''. |
| A. | float *(ptr)*int; |
| B. | float *(*ptr)(int) |
| C. | float *(*ptr)(int*) |
| D. | float (*ptr)(int) |
| Answer» D. float (*ptr)(int) | |
| 18. |
Declare the following statement?''A pointer to an array of three chars'' |
| A. | char *ptr[3](); |
| B. | char (*ptr)*[3]; |
| C. | char (*ptr[3])(); |
| D. | char (*ptr)[3]; |
| Answer» E. | |
| 19. |
What will be the output of the program? #include int main() { struct s1 { char *z; int i; struct s1 *p; }; static struct s1 a[] = {{"Nagpur", 1, a+1} , {"Chennai", 2, a+2} , {"Bangalore", 3, a} }; struct s1 *ptr = a; printf("%s,", ++(ptr->z)); printf(" %s,", a[(++ptr)->i].z); printf(" %s", a[--(ptr->p->i)].z); return 0; } |
| A. | Nagpur, Chennai, Bangalore |
| B. | agpur, hennai, angalore |
| C. | agpur, Chennai, angalore |
| D. | agpur, Bangalore, Bangalore |
| Answer» E. | |
| 20. |
What will be the output of the program under DOS? #include int main() { char huge *near *far *ptr1; char near *far *huge *ptr2; char far *huge *near *ptr3; printf("%d, %d, %d\n", sizeof(ptr1), sizeof(**ptr2), sizeof(ptr3)); return 0; } |
| A. | 4, 4, 4 |
| B. | 4, 2, 2 |
| C. | 2, 8, 4 |
| D. | 2, 4, 8 |
| Answer» C. 2, 8, 4 | |
| 21. |
What will be the output of the program in Turbo C? #include int main() { char near *near *ptr1; char near *far *ptr2; char near *huge *ptr3; printf("%d, %d, %d\n", sizeof(ptr1), sizeof(ptr2), sizeof(ptr3)); return 0; } |
| A. | 4, 4, 8 |
| B. | 4, 4, 4 |
| C. | 2, 4, 8 |
| D. | 2, 4, 4 |
| Answer» E. | |
| 22. |
What will be the output of the program in DOS (Compiler - Turbo C)? #include double i; int main() { (int)(float)(char) i; printf("%d",sizeof(i)); return 0; } |
| A. | 4 |
| B. | 8 |
| C. | 16 |
| D. | 22 |
| Answer» C. 16 | |
| 23. |
What will be the output of the program? #include typedef unsigned long int uli; typedef uli u; int main() { uli a; u b = -1; a = -1; printf("%lu, %lu", a, b); return 0; } |
| A. | 4343445454, 4343445454 |
| B. | 4545455434, 4545455434 |
| C. | 4294967295, 4294967295 |
| D. | Garbage values |
| Answer» D. Garbage values | |
| 24. |
Point out the error in the following program. #include #include int main() { static char *p = (char *)malloc(10); return 0; } |
| A. | Error: Lvalue required |
| B. | Error: Rvalue required |
| C. | Error: invalid *p declaration |
| D. | No error |
| Answer» E. | |
| 25. |
We can modify the pointers "source" as well as "target". |
| A. | 1 |
| B. | |
| Answer» B. | |
| 26. |
Are the following declarations same? char far *far *scr; char far far** scr; |
| A. | Yes |
| B. | No |
| Answer» C. | |
| 27. |
What will be the output of the program? #include int main() { char huge *near *ptr1; char huge *far *ptr2; char huge *huge *ptr3; printf("%d, %d, %d\n", sizeof(ptr1), sizeof(ptr2), sizeof(ptr3)); return 0; } |
| A. | 4, 4, 8 |
| B. | 2, 4, 4 |
| C. | 4, 4, 2 |
| D. | 2, 4, 8 |
| Answer» C. 4, 4, 2 | |
| 28. |
What do the following declaration signify? int *f(); |
| A. | f is a pointer variable of function type. |
| B. | f is a function returning pointer to an int. |
| C. | f is a function pointer. |
| D. | f is a simple declaration of pointer variable. |
| Answer» C. f is a function pointer. | |
| 29. |
What will be the output of the program? #include typedef void v; typedef int i; int main() { v fun(i, i); fun(2, 3); return 0; } v fun(i a, i b) { i s=2; float i; printf("%d,", sizeof(i)); printf(" %d", a*b*s); } |
| A. | 2, 8 |
| B. | 4, 8 |
| C. | 2, 4 |
| D. | 4, 12 |
| Answer» E. | |
| 30. |
It is not necessary to typecast the address returned by malloc(). |
| A. | 1 |
| B. | |
| Answer» C. | |
| 31. |
What will be the output of the program? #include int main() { char huge *near *far *ptr1; char near *far *huge *ptr2; char far *huge *near *ptr3; printf("%d, %d, %d\n", sizeof(**ptr1), sizeof(ptr2), sizeof(*ptr3)); return 0; } |
| A. | 4, 4, 4 |
| B. | 2, 2, 2 |
| C. | 2, 8, 4 |
| D. | 2, 4, 8 |
| Answer» B. 2, 2, 2 | |
| 32. |
Is the following declaration correct?char far *far *ptr; |
| A. | Yes |
| B. | No |
| Answer» B. No | |
| 33. |
What will be the output of the program? #include int main() { char huge *near *far *ptr1; char near *far *huge *ptr2; char far *huge *near *ptr3; printf("%d, %d, %d\n", sizeof(ptr1), sizeof(*ptr2), sizeof(**ptr3)); return 0; } |
| A. | 4, 4, 4 |
| B. | 2, 4, 4 |
| C. | 4, 4, 2 |
| D. | 2, 4, 8 |
| Answer» B. 2, 4, 4 | |
| 34. |
Function can return a floating point number. |
| A. | 1 |
| B. | |
| Answer» B. | |
| 35. |
Point out the error in the following program. #include void display(int (*ff)()); int main() { int show(); int (*f)(); f = show; display(f); return 0; } void display(int (*ff)()) { (*ff)(); } int show() { printf("IndiaBIX"); } |
| A. | Error: invalid parameter in function display() |
| B. | Error: invalid function call f=show; |
| C. | No error and prints "IndiaBIX" |
| D. | No error and prints nothing. |
| Answer» D. No error and prints nothing. | |
| 36. |
What will be the output of the program in DOS (Compiler - Turbo C)? #include double i; int main() { (int)(float)(char) i; printf("%d", sizeof((int)(float)(char)i)); return 0; } |
| A. | 1 |
| B. | 2 |
| C. | 4 |
| D. | 8 |
| Answer» C. 4 | |
| 37. |
What do the following declaration signify? char *scr; |
| A. | scr is a pointer to pointer variable. |
| B. | scr is a function pointer. |
| C. | scr is a pointer to char. |
| D. | scr is a member of function pointer. |
| Answer» D. scr is a member of function pointer. | |
| 38. |
What do the following declaration signify? void *cmp(); |
| A. | cmp is a pointer to an void type. |
| B. | cmp is a void type pointer variable. |
| C. | cmp is a function that return a void pointer. |
| D. | cmp function returns nothing. |
| Answer» D. cmp function returns nothing. | |
| 39. |
Is the following declaration correct?void(*f)(int, void(*)()); |
| A. | Yes |
| B. | No |
| Answer» B. No | |
| 40. |
Declare the following statement? "A pointer to a function which receives nothing and returns nothing". |
| A. | void *(ptr)*int; |
| B. | void *(*ptr)() |
| C. | void *(*ptr)(*) |
| D. | void (*ptr)() |
| Answer» E. | |
| 41. |
Is the following declaration correct?char (* ( *f())[])(); |
| A. | Yes |
| B. | No |
| Answer» B. No | |
| 42. |
We can allocate a 2-Dimensional array dynamically. |
| A. | 1 |
| B. | |
| Answer» B. | |
| 43. |
What do the following declaration signify? void (*cmp)(); |
| A. | cmp is a pointer to an void function type. |
| B. | cmp is a void type pointer function. |
| C. | cmp is a function that return a void pointer. |
| D. | cmp is a pointer to a function which returns void . |
| Answer» E. | |
| 44. |
What will be the output of the program (in Turbo C under DOS)? #include int main() { char huge *near *far *ptr1; char near *far *huge *ptr2; char far *huge *near *ptr3; printf("%d, %d, %d\n", sizeof(ptr1), sizeof(ptr2), sizeof(ptr3)); return 0; } |
| A. | 4, 4, 8 |
| B. | 2, 4, 4 |
| C. | 4, 4, 2 |
| D. | 2, 4, 8 |
| Answer» D. 2, 4, 8 | |
| 45. |
What do the following declaration signify? int (*pf)(); |
| A. | pf is a pointer to function. |
| B. | pf is a function pointer. |
| C. | pf is a pointer to a function which return int |
| D. | pf is a function of pointer variable. |
| Answer» D. pf is a function of pointer variable. | |
| 46. |
Declare the following statement? "A pointer to an array of three chars". |
| A. | char *ptr[3](); |
| B. | char (*ptr)*[3]; |
| C. | char (*ptr[3])(); |
| D. | char (*ptr)[3]; |
| Answer» E. | |
| 47. |
Point out the error in the following program (in Turbo C under DOS). #include union emp { int empno; int age; }; int main() { union emp e = {10, 25}; printf("%d %d", e.empno, e.age); return 0; } |
| A. | Error: Lvalue required |
| B. | Error: Rvalue required |
| C. | Error: cannot initialize more than one union member. |
| D. | No error |
| Answer» D. No error | |
| 48. |
What do the following declaration signify? char *arr[10]; |
| A. | arr is a array of 10 character pointers. |
| B. | arr is a array of function pointer. |
| C. | arr is a array of characters. |
| D. | arr is a pointer to array of characters. |
| Answer» B. arr is a array of function pointer. | |
| 49. |
Does the data type of all elements in the union will be same. |
| A. | 1 |
| B. | |
| C. | 1 |
| D. | |
| Answer» C. 1 | |
| 50. |
What do the following declaration signify? char **argv; |
| A. | argv is a pointer to pointer. |
| B. | argv is a pointer to a char pointer. |
| C. | argv is a function pointer. |
| D. | argv is a member of function pointer. |
| Answer» C. argv is a function pointer. | |