C Questions March 18, 2023 | No Comments 0 votes, 0 avg 134 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. Comment on the output of the following C code. #include struct temp { int a; int b; int c; }; main() { struct temp p[] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; } A. No Compile time error, generates an array of structure of size 3 B. No Compile time error, generates an array of structure of size 9 C. Compile time error, illegal declaration of a multidimensional array D. Compile time error, illegal assignment to members of structure 3 / 15 3. 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 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 4 5 0 B. 1 2 3 4 5 junk C. 1 2 3 4 5 5 D. Run time error 5 / 15 5. What will fopen will return, if there is any error while opening a file? A. Nothing B. EOF C. NULL D. Depends on compiler 6 / 15 6. What is #include < stdio.h > ? A. Preprocessor directive B. Inclusion directive C. File inclusion directive D. None of the mentioned 7 / 15 7. What will be the output of the following C code? #include #include void main() { int k = pow(2, 3); printf("%dn", k); } A. 9 B. 8 C. -1 D. 6 8 / 15 8. What will happen if a header file is included in a program twice? A. Program will throw an error B. Program will throw an exception C. Program will run normally D. None of these 9 / 15 9. 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 10 / 15 10. Which of the following is not a valid C variable name? A. int number; B. float rate; C. int variable_count; D. int $main; 11 / 15 11. Why do variable names beginning with the underscore is not encouraged? A. It is not standardized B. To avoid conflicts since assemblers and loaders use such names C. To avoid conflicts since library routines use such names D. To avoid conflicts with environment variables of an operating system 12 / 15 12. Libray function getch() belongs to which header file? A. stdio.h B. conio.h C. stdlib.h D. stdlibio.h 13 / 15 13. 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 14 / 15 14. Multiple values of the same variable can be tested using ___. A. switch B. for C. function D. All of these 15 / 15 15. What will be the output of the following C code? #include void foo(int *ary[]); int main() { int ary[2][3]; foo(ary); } void foo(int *ary[]) { int i = 10, j = 2, k; ary[0] = &i; ary[1] = &j; *ary[0] = 2; for (k = 0;k < 2; k++) printf("%dn", *ary[k]); } A. 2 2 B. Compile time error C. Undefined behaviour D. 10 2 Your score is The average score is 30% LinkedIn Facebook Twitter VKontakte 0% Restart quiz Questions, Quiz