C Questions March 18, 2023 | No Comments 0 votes, 0 avg 697 123456789101112131415 C Questions 1 / 15 1. What will be the output of the following C code? #include int main() { enum {ORANGE = 5, MANGO, BANANA = 4, PEACH}; printf("PEACH = %dn", PEACH); } A. PEACH = 3 B. PEACH = 4 C. PEACH = 5 D. PEACH = 6 2 / 15 2. Which option should be selected to work the following C expression? string p = "HELLO"; A. typedef char [] string; B. typedef char *string; C. typedef char [] string; and typedef char *string; D. Such expression cannot be generated in C 3 / 15 3. In C, parameters are always A. Passed by value B. Passed by reference C. Non-pointer variables are passed by value and pointers are passed by reference D. Passed by value result 4 / 15 4. What is the output of C Program.? int main() { int a=10,b=20; if(a==9 AND b==20) { printf("Hurray.."); } if(a==10 OR b==21) { printf("Theatre"); } return 0; } A. Theatre B. Hurray Theatre C. No output D. Compiler error 5 / 15 5. What will be the output of the following C code if following commands are used to run (considering myfile exists)? A. Compile time error (after first command) B. d in the myfile file C. d on the screen D. Undefined behaviour 6 / 15 6. The standard header _______ is used for variable list arguments (…) in C. A. stdio.h B. stdlib.h C. math.h D. stdarg.h 7 / 15 7. Which of the following is true for the static variable? A. It can be called from another function B. It exists even after the function ends C. It can be modified in another function by sending it as a parameter D. All of the mentioned 8 / 15 8. What is the disadvantage of arrays in C? A. The amount of memory to be allocated should be known beforehand B. Elements of an array can be accessed in constant time C. Elements are stred in contiguous memory blocks D. Multiple other data structures can be implemented using array. 9 / 15 9. What will be the output of the following C program? #include int main() { int x[5] = { 10, 20, 30 }; printf("%ld", sizeof(x)/sizeof(x[0])); return 0; } A. 3 B. 4 C. 5 D. 6 10 / 15 10. What will be the output of the following C code? #include int main(){ char grade = 'B'; switch (grade) { case 'A': printf("Excellent!n"); case 'B': case 'C': printf("Well donen"); case 'D': printf("You passedn"); case 'F': printf("Better try againn"); break; default: printf("Invalid graden"); } } A. Well done B. You passed C. Better try again D. All of these 11 / 15 11. What will be the output of the following code snippet? #include void solve() { int ch = 2; switch(ch) { case 1: printf("1 "); case 2: printf("2 "); case 3: printf("3 "); default: printf("None"); } } int main() { solve(); return 0; } A. 1 2 3 None B. 2 C. 2 3 None D. None 12 / 15 12. Array sizes are optional during array declaration by using ______ keyword. A. auto B. static C. extern D. register 13 / 15 13. What is output of below program? int main() { int i,j; for(i = 0,j=0;i<5;i++) { printf("%d%d--",i,j); } return 0; } A. 0--01--12--23--34-- B. 00--10--20--30--40-- C. Compilation Error D. 00--01--02--03--04-- 14 / 15 14. If p is an integer pointer with a value 1000, then what will the value of p + 5 be? A. 1020 B. 1005 C. 1004 D. 1010 15 / 15 15. What will be the output of the following C code? #include int *m(); void main() { int *k = m(); printf("hello "); printf("%d", k[0]); } int *m() { int a[2] = {5, 8}; return a; } A. Hello 5 8 B. Hello 5 C. hello followed by garbage value D. Compilation error Your score isThe average score is 39% LinkedIn Facebook VKontakte 0% Restart quiz By WordPress Quiz plugin Questions, Quiz