

MCQOPTIONS
Saved Bookmarks
This section includes 35 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 an array that holds information needed by and |
A. | True |
B. | False |
Answer» B. False | |
2. |
The macro is used to initialise a pointer to the beginning of the list of fixed arguments. |
A. | True |
B. | False |
Answer» C. | |
3. |
The macro is used to extract an argument from the fixed micro argument list and advance the pointer to the next argument. |
A. | Yes |
B. | No |
Answer» C. | |
4. |
It is necessary to call the macro if is called in the function. |
A. | Yes |
B. | No |
Answer» B. No | |
5. |
The macro is used to extract an argument from the variable argument list and advance the pointer to the next argument. |
A. | True |
B. | False |
Answer» B. False | |
6. |
A function that receives variable number of arguments should use to extract arguments from the variable argument list. |
A. | True |
B. | False |
Answer» B. False | |
7. |
A function that receives variable number of arguments should use to extract the last argument from the variable argument list. |
A. | True |
B. | False |
Answer» C. | |
8. |
Point out the error in the following program._x000D_ #include_x000D_ #include_x000D_ _x000D_ int main()_x000D_ {_x000D_ void display(int num, ...);_x000D_ display(4, 12.5, 13.5, 14.5, 44.3);_x000D_ return 0;_x000D_ }_x000D_ void display(int num, ...)_x000D_ {_x000D_ float c; int j;_x000D_ va_list ptr;_x000D_ va_start(ptr, num);_x000D_ for(j=1; j |
A. | Error: invalid va_list declaration |
B. | Error: var c data type mismatch |
C. | No error |
D. | No error and Nothing will print |
Answer» C. No error | |
9. |
Which header file should you include, if you are going to develop a function, which can accept variable number of arguments? |
A. | varagrg.h |
B. | stdlib.h |
C. | stdio.h |
D. | stdarg.h |
Answer» E. | |
10. |
The macro va_arg is used to extract an argument from the fixed micro argument list and advance the pointer to the next argument. |
A. | Yes |
B. | No |
Answer» C. | |
11. |
Point out the error in the following program. #include #include void varfun(int n, ...); int main() { varfun(3, 7, -11.2, 0.66); return 0; } void varfun(int n, ...) { float *ptr; int num; va_start(ptr, n); num = va_arg(ptr, int); printf("%d", num); } |
A. | Error: too many parameters |
B. | Error: invalid access to list member |
C. | Error: ptr must be type of va_list |
D. | No error |
Answer» D. No error | |
12. |
The macro va_start is used to initialise a pointer to the beginning of the list of fixed arguments. |
A. | 1 |
B. | |
Answer» C. | |
13. |
It is necessary to call the macro va_end if va_start is called in the function. |
A. | Yes |
B. | No |
C. | Yes |
D. | No |
Answer» B. No | |
14. |
A function that receives variable number of arguments should use va_arg() to extract the last argument from the variable argument list. |
A. | 1 |
B. | |
Answer» C. | |
15. |
Is it necessary that in a function which accepts variable argument list there should be at least be one fixed argument? |
A. | Yes |
B. | No |
Answer» B. No | |
16. |
A function that receives variable number of arguments should use va_arg() to extract arguments from the variable argument list. |
A. | 1 |
B. | |
Answer» B. | |
17. |
Point out the error if any in the following program (Turbo C). #include #include void display(int num, ...); int main() { display(4, 'A', 'a', 'b', 'c'); return 0; } void display(int num, ...) { char c; int j; va_list ptr; va_start(ptr, num); for(j=1; j |
A. | Error: unknown variable ptr |
B. | Error: Lvalue required for parameter |
C. | No error and print A a b c |
D. | No error and print 4 A a b c |
Answer» D. No error and print 4 A a b c | |
18. |
Point out the error in the following program. #include #include void display(char *s, ...); void show(char *t, ...); int main() { display("Hello", 4, 12, 13, 14, 44); return 0; } void display(char *s, ...) { show(s, ...); } void show(char *t, ...) { int a; va_list ptr; va_start(ptr, s); a = va_arg(ptr, int); printf("%f", a); } |
A. | Error: invalid function display() call |
B. | Error: invalid function show() call |
C. | No error |
D. | Error: Rvalue required for t |
Answer» C. No error | |
19. |
va_list is an array that holds information needed by va_arg and va_end |
A. | 1 |
B. | |
C. | 1 |
D. | |
Answer» B. | |
20. |
Point out the error in the following program. #include #include int main() { void display(int num, ...); display(4, 12.5, 13.5, 14.5, 44.3); return 0; } void display(int num, ...) { float c; int j; va_list ptr; va_start(ptr, num); for(j=1; j |
A. | Error: invalid va_list declaration |
B. | Error: var c data type mismatch |
C. | No error |
D. | No error and Nothing will print |
Answer» C. No error | |
21. |
For a function receives variable number of arguments it is necessary that the function should receive at least one fixed argument. |
A. | 1 |
B. | |
Answer» B. | |
22. |
Can we write a function that takes a variable argument list and passes the list to another function? |
A. | Yes |
B. | No |
Answer» B. No | |
23. |
Point out the error in the following program. #include #include void varfun(int n, ...); int main() { varfun(3, 7, -11, 0); return 0; } void varfun(int n, ...) { va_list ptr; int num; num = va_arg(ptr, int); printf("%d", num); } |
A. | Error: ptr has to be set at begining |
B. | Error: ptr must be type of va_list |
C. | Error: invalid access to list member |
D. | No error |
Answer» B. Error: ptr must be type of va_list | |
24. |
In a function that receives variable number of arguments the fixed arguments passed to the function can be at the end of argument list. |
A. | 1 |
B. | |
Answer» C. | |
25. |
While defining a variable argument list function we drop the ellipsis(...)? |
A. | Yes |
B. | No |
Answer» B. No | |
26. |
Point out the error in the following program. #include #include int main() { void display(char *s, int num1, int num2, ...); display("Hello", 4, 2, 12.5, 13.5, 14.5, 44.0); return 0; } void display(char *s, int num1, int num2, ...) { double c; char s; va_list ptr; va_start(ptr, s); c = va_arg(ptr, double); printf("%f", c); } |
A. | Error: invalid arguments in function display() |
B. | Error: too many parameters |
C. | Error: in va_start(ptr, s); |
D. | No error |
Answer» D. No error | |
27. |
Can the fixed arguments passed to the function that accepts variable argument list, occur at the end? |
A. | Yes |
B. | No |
Answer» C. | |
28. |
What will be the output of the program? #include #include void fun1(char, int, int *, float *, char *); void fun2(char ch, ...); void (*p1)(char, int, int *, float *, char *); void (*p2)(char ch, ...); int main() { char ch='A'; int i=10; float f=3.14; char *p="Hello"; p1=fun1; p2=fun2; (*p1)(ch, i, &i, &f, p); (*p2)(ch, i, &i, &f, p); return 0; } void fun1(char ch, int i, int *pi, float *pf, char *p) { printf("%c %d %d %f %s \n", ch, i, *pi, *pf, p); } void fun2(char ch, ...) { int i, *pi; float *pf; char *p; va_list list; printf("%c ", ch); va_start(list, ch); i = va_arg(list, int); printf("%d ", i); pi = va_arg(list, int*); printf("%d ", *pi); pf = va_arg(list, float*); printf("%f ", *pf); p = va_arg(list, char *); printf("%s", p); } |
A. | A 10 3.14 A 10 3.14 |
B. | A 10 10 3.140000 Hello A 10 10 3.140000 Hello |
C. | A 10 Hello A 10 Hello |
D. | Error |
Answer» C. A 10 Hello A 10 Hello | |
29. |
Can we pass a variable argument list to a function at run-time? |
A. | Yes |
B. | No |
C. | Yes |
D. | No |
Answer» C. Yes | |
30. |
Point out the error in the following program. #include #include fun(...); int main() { fun(3, 7, -11.2, 0.66); return 0; } fun(...) { va_list ptr; int num; va_start(ptr, n); num = va_arg(ptr, int); printf("%d", num); } |
A. | Error: fun() needs return type |
B. | Error: ptr Lvalue required |
C. | Error: Invalid declaration of fun(...) |
D. | No error |
Answer» D. No error | |
31. |
The macro va_arg is used to extract an argument from the variable argument list and advance the pointer to the next argument. |
A. | 1 |
B. | |
C. | 1 |
D. | |
Answer» B. | |
32. |
What will be the output of the program? #include #include void fun1(int num, ...); void fun2(int num, ...); int main() { fun1(1, "Apple", "Boys", "Cats", "Dogs"); fun2(2, 12, 13, 14); return 0; } void fun1(int num, ...) { char *str; va_list ptr; va_start(ptr, num); str = va_arg(ptr, char *); printf("%s ", str); } void fun2(int num, ...) { va_list ptr; va_start(ptr, num); num = va_arg(ptr, int); printf("%d", num); } |
A. | Dogs 12 |
B. | Cats 14 |
C. | Boys 13 |
D. | Apple 12 |
Answer» E. | |
33. |
What will be the output of the program? #include #include void dumplist(int, ...); int main() { dumplist(2, 4, 8); dumplist(3, 6, 9, 7); return 0; } void dumplist(int n, ...) { va_list p; int i; va_start(p, n); while(n-->0) { i = va_arg(p, int); printf("%d", i); } va_end(p); printf("\n"); } |
A. | 2 4 3 6 |
B. | 2 4 8 3, 6, 9, 7 |
C. | 4 8 6 9 7 |
D. | 1 1 1 1 1 1 1 |
Answer» D. 1 1 1 1 1 1 1 | |
34. |
What will be the output of the program? #include #include void display(int num, ...); int main() { display(4, 'A', 'B', 'C', 'D'); return 0; } void display(int num, ...) { char c, c1; int j; va_list ptr, ptr1; va_start(ptr, num); va_start(ptr1, num); for(j=1; j |
A. | A, AB, BC, CD, D |
B. | A, aB, bC, cD, d |
C. | A, 65B, 66C, 67D, 68 |
D. | A, 0B, 0C, 0C, 0 |
Answer» D. A, 0B, 0C, 0C, 0 | |
35. |
What will be the output of the program? #include #include void fun(char *msg, ...); int main() { fun("IndiaBIX", 1, 4, 7, 11, 0); return 0; } void fun(char *msg, ...) { va_list ptr; int num; va_start(ptr, msg); num = va_arg(ptr, int); num = va_arg(ptr, int); printf("%d", num); } |
A. | IndiaBIX 1 7 11 0 |
B. | 1 |
C. | 4 |
D. | 7 |
Answer» D. 7 | |