C QuestionsBy Kritika Papne / March 18, 2023 0 votes, 0 avg 742 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. What type of array is generally generated in Command-line argument? A. Single dimension array B. 2-Dimensional Square Array C. Jagged Array D. 2-Dimensional Rectangular Array 3 / 15 3. What will be the output of the following C program? #include union values { int val1; char val2; } myVal; int main() { myVal.val1 = 66; printf("val1 = %p", &myVal.val1); printf("nval2 = %p", &myVal.val2); return 0; } A. val1 = 0x54ac88dd2012 val2 = 0x55ac76dd2014 B. Error C. val1 = 0x55ac76dd2014 val2 = 0x55ac76dd2014 D. Exception 4 / 15 4. Property which allows to produce different executable for different platforms in C is called? A. File inclusion B. Selective inclusion C. Conditional compilation D. Recursive macros 5 / 15 5. What will be the final values of i and j in the following C code? #include int x = 0; int f() { if (x == 0) return x + 1; else return x - 1; } int g() { return x++; } int main() { int i = (f() + g()) | g(); //bitwise or int j = g() | (f() + g()); //bitwise or } A. i value is 1 and j value is 1 B. i value is 0 and j value is 0 C. i value is 1 and j value is undefined D. i and j value are undefined 6 / 15 6. What will be the output of the following C code? #include #include int main() { char line[3]; FILE *fp; fp = fopen("newfile.txt", "r"); while (fgets(line, 3, fp)) fputs(line, stdout); return 0; } A. Compilation error B. Infinite loop C. Segmentation fault D. No.of lines present in file newfile 7 / 15 7. Identify X library function for line input and output in the following C code? A. fputs B. getc C. putc D. fgets 8 / 15 8. What is storage class for variable A in below code? int main() { int A; A = 10; printf("%d", A); return 0; } A. extern B. auto C. register D. static 9 / 15 9. Which C keyword is used to extend the visibility of variables? A. extend B. extends C. extern D. auto 10 / 15 10. What does argc and argv indicate in command-line arguments? (Assuming: int main(int argc, char *argv[]) ) A. argument count, argument variable B. argument count, argument vector C. argument control, argument variable D. argument control, argument vector 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. Which statement is required to execute a block of code when the condition is false? A. for B. if C. else D. All of these 13 / 15 13. What will be the output of the following C code? #include int main() { int x = 0; if (x == 1) if (x == 0) printf("inside ifn"); else printf("inside else ifn"); else printf("inside elsen"); } A. inside if B. inside else if C. inside else D. compile time error 14 / 15 14. 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 15 / 15 15. What will be the output of the following code snippet? #include void solve() { int first = 10, second = 20; int third = first + second; { int third = second - first; printf("%d ", third); } printf("%d", third); } int main() { solve(); return 0; } A. 10 30 B. 30 10 C. 10 20 D. 20 10 Your score isThe average score is 38% LinkedIn Facebook VKontakte 0% Restart quiz By WordPress Quiz plugin Written by Shubhranshu Shekhar, who has trained 20000+ students in coding. Kritika Papne