C Questions March 18, 2023 | No Comments 0 votes, 0 avg 726 123456789101112131415 C Questions 1 / 15 1. Global variables are ____________ A. Internal B. External C. Both Internal and External D. None of the mentioned 2 / 15 2. What will be the output of the following C code? #include int main() { float x = 21.0; x %= 3.0; printf("%f",x); return 0; } A. 7 B. 7.oo C. 7.oooooo D. error 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. What will be the output of the following C code? #include void main() { int a[2][3] = {1, 2, 3, , 4, 5}; int i = 0, j = 0; for (i = 0; i < 2; i++) for (j = 0; j < 3; j++) printf("%d", a[i][j]); } A. 1 2 3 junk 4 5 B. Compile time error C. 1 2 3 0 4 5 D. 1 2 3 3 4 5 5 / 15 5. 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 6 / 15 6. What will be the output of the following C code? #include void main() { int a[2][3] = {1, 2, 3, 4, 5}; int i = 0, j = 0; for (i = 0; i < 2; i++) for (j = 0; j < 3; j++) printf("%d", a[i][j]); } A. 1 2 3 4 5 0 B. 1 2 3 4 5 junk C. 1 2 3 4 5 5 D. Run time error 7 / 15 7. What will be the output of the following C code? #include struct student { int no = 5; char name[20]; }; void main() { struct student s; s.no = 8; printf("hello"); } A. Nothing B. Compile time error C. hello D. Varies 8 / 15 8. What will be the output of the following code snippet? #include void solve() { int a = 3; int res = a++ + ++a + a++ + ++a; printf("%d", res); } int main() { solve(); return 0; } A. 12 B. 24 C. 20 D. 18 9 / 15 9. Which of the following is not a valid C variable name? A. int number; B. float rate; C. int variable_count; D. int $main; 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. double ______ (double x, double y) computes the floating-point remainder of x/y. A. modf B. fmod C. ceil D. floor 12 / 15 12. 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 13 / 15 13. What will be the output of the following C code? #include int main() { const int ary[4] = {1, 2, 3, 4}; int *p; p = ary + 3; *p = 5; printf("%dn", ary[3]); } A. 4 B. 5 C. Compile time error D. 3 14 / 15 14. 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 15 / 15 15. 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 Your score isThe average score is 38% LinkedIn Facebook VKontakte 0% Restart quiz By WordPress Quiz plugin Questions, Quiz