C/C MCQ Quiz Hub

C Multiple Choice Questions C Functions Set 1

Choose a topic to test your knowledge and improve your C/C skills

1. What is the output of this C code? int main() { void foo(), f(); f(); } void foo() { printf("2 "); } void f() { printf("1 "); foo(); }




2. What is the output of this C code? int main() { void foo(); void f() { foo(); } f(); } void foo() { printf("2 "); }




3. What is the output of this C code? void foo(); int main() { void foo(); foo(); return 0; } void foo() { printf("2 "); }




4. What is the output of this C code? void foo(); int main() { void foo(int); foo(1); return 0; } void foo(int i) { printf("2 "); }




5. What is the output of this C code? void m() { printf("hi"); } void main() { m(); }




6. What is the output of this C code? void m() { printf("hi"); } void main() { m(); }




7. What is the output of this C code? void m(); void n() { m(); } void main() { void m() { printf("hi"); } }




8. What is the output of this C code? void main() { m(); void m() { printf("hi"); } }




9. What is the output of this C code? void main() { m(); } void m() { printf("hi"); m(); }




10. What is the output of this C code? void main() { static int x = 3; x++; if (x <= 5) { printf("hi"); main(); } }




11. Which of the following function declaration is illegal?




12. Which function definition will run correctly?




13. Can we use a function as a parameter of another function? [ Eg: void wow(int func()) ]




14. The value obtained in the function is given back to main by using ________ keyword?




15. What is the return-type of the function sqrt()




16. Which of the following function declaration is illegal?




17. What is the output of this code having void return-type function? void foo() { return 1; } void main() { int x = 0; x = foo(); printf("%d", x); }




18. What will be the data type returned for the following function? int func() { return (double)(char)5.0; }




19. What is the problem in the following declarations? int func(int); double func(int); int func(float);




20. The output of the code below is void main() { int k = m(); printf("%d", k); } void m() { printf("hello"); }




21. The output of the code below is int *m() { int *p = 5; return p; } void main() { int *k = m(); printf("%d", k); }




22. The output of the code below is int *m(); void main() { int *k = m(); printf("hello "); printf("%d", k[0]); } int *m() { int a[2] = {5, 8}; return a; }




23. The output of the code below is int *m(); void main() { int k = m(); printf("%d", k); } int *m() { int a[2] = {5, 8}; return a; }




24. The output of the code below is void m(int k) { printf("hi"); } void m(double k) { printf("hello"); } void main() { m(3); }




25. What is the default return type if it is not specified in function definition?




26. What is the output of this C code? int foo(); int main() { int i = foo(); } foo() { printf("2 "); return 2; }




27. What is the output of this C code? double foo(); int main() { foo(); return 0; } foo() { printf("2 "); return 2; }




28. functions can return structure in c?




29. functions can return enumeration constants in c?




30. What is the output of this C code? void main() { m(); printf("%d", x); } int x; void m() { x = 4; }




31. What is the output of this C code? int x; void main() { printf("%d", x); }




32. What is the output of this C code? int x = 5; void main() { int x = 3; printf("%d", x); { x = 4; } printf("%d", x); }




33. What is the output of this C code? int x = 5; void main() { int x = 3; printf("%d", x); { int x = 4; } printf("%d", x); }




34. Functions in C are ALWAYS:




35. Which of the following are an external variable? int func (int a) { int b; return b; } int main() { int c; func (c); } int d;




36. What will be the output? int main() { printf("%d", d++); } int d = 10;




37. What will be the output? double var = 8; int main() { int var = 5; printf("%d", var); }




38. What is the output of this C code? double i; int main() { printf("%g ",i); return 0; }




39. Which part of the program address space is p stored in the code given below? int *p; int main() { int i = 0; p = &i; return 0; }




40. Can variable i be accessed by functions in another source file? int i; int main() { printf("%d ", i); }




41. Property of external variable to be accessed by any source file is called by C90 standard as:




42. What is the output of this C code? int *i; int main() { if (i == NULL) printf("true "); return 0; }




43. What is the output of this C code? int *i; int main() { if (i == 0) printf("true "); return 0; }




44. What is the output of this C code? static int x = 5; void main() { x = 9; { int x = 4; } printf("%d", x); }




45. What is the output of this C code? void main() { m(); m(); } void m() { static int x = 5; x++; printf("%d", x); }




46. What is the output of this C code? void main() { static int x; printf("x is %d", x); }




47. What is the output of this C code? static int x; void main() { int x; printf("x is %d", x);




48. What is the output of this C code? void main() { static double x; int x; printf("x is %d", x); }




49. What is the output of this C code? void main() { static int x; if (x++ < 2) main(); }




50. Which of following is not accepted in C?




51. Which of the following cannot be static in C?




52. The scope of an automatic variable is:




53. Automatic variables are allocated space in the form of a:




54. Which of the following is a storage specifier?




55. Default storage class if not any is specified for a local variable, is auto:




56. Automatic variables are stored in:




57. What linkage does automatic variables have?




58. What is the output of this C code? int main() { auto i = 10; const auto int *p = &i; printf("%d ", i); }