C QuestionsBy Kritika Papne / March 18, 2023 0 votes, 0 avg 749 123456789101112131415 C Questions 1 / 15 1. 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 2 / 15 2. 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 3 / 15 3. What will be the output of this program? int main() { int a=10, b=20; printf("a=%d b=%d",a,b); a=a+b; b=a-b; a=a-b; printf("a=%d b=%d",a,b); return 0; } A. a = 20, b = 20 B. a=10, b=20 C. a=20, b=10 D. a=10, b=10 4 / 15 4. What will be the output of the following C code? #include void main() { double k = 0; for (k = 0.0; k < 3.0; k++) printf("Hello"); } A. Run time error B. Hello is printed thrice C. Hello is printed twice D. Hello is printed infinitely 5 / 15 5. What will be the output of the following C code? #include int main() { float x = 23.456; printf("%.2f",x); return 0; } A. 23.456OO B. 23.456 C. 23.45 D. 23.46 6 / 15 6. 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 7 / 15 7. What is an example of iteration in C? A. for B. while C. Do-while D. All of these 8 / 15 8. What is the output of the following code snippet? #include int main() { int a[] = {1, 2, 3, 4}; int sum = 0; for(int i = 0; i < 4; i++) { sum += a[i]; } printf("%d", sum); return 0; } A. 1 B. 4 C. 20 D. 10 9 / 15 9. 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 10 / 15 10. The standard header _______ is used for variable list arguments (…) in C. A. stdio.h B. stdlib.h C. math.h D. stdarg.h 11 / 15 11. What will be the output of the following C code considering the size of a short int is 2, char is 1 and int is 4 bytes? #include int main() { short int i = 20; char c = 97; printf("%d, %d, %dn", sizeof(i), sizeof(c), sizeof(c + i)); return 0; } A. 2, 1, 2 B. 2, 1, 1 C. 2, 1, 4 D. 2, 2, 8 12 / 15 12. What will be the output of the following C code? #include struct student { char *name; }; struct student s[2]; void main() { s[0].name = "alan"; s[1] = s[0]; printf("%s%s", s[0].name, s[1].name); s[1].name = "turing"; printf("%s%s", s[0].name, s[1].name); } A. alan alan alan turing B. alan alan turing turing C. alan turing alan turing D. run time error 13 / 15 13. What is the use of symbol * in the control string as shown [=%[*][width] [modifiers] type=]? A. * is not optional, used to read data from the stream but it is not ignored B. * is optional and used when the data should be read from the stream but ignored C. * is not optional, it is used to read data stream but ignored D. * is optional and used to read data from stream but it is not ignored 14 / 15 14. What will be the output of the following code snippet? #include void solve() { int a[] = {1, 2, 3, 4, 5}; int sum = 0; for(int i = 0; i < 5; i++) { if(i % 2 == 0) { sum += *(a + i); } else { sum -= *(a + i); } } printf("%d", sum); } int main() { solve(); return 0; } A. 2 B. 15 C. syntax error D. 3 15 / 15 15. 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 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