MCQOPTIONS
Saved Bookmarks
This section includes 657 Mcqs, each offering curated multiple-choice questions to sharpen your Testing Subject knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
what does the default header file contain? |
| A. | Declarations |
| B. | Implementations |
| C. | Prototypes |
| D. | All of the above |
| Answer» B. Implementations | |
| 2. |
All keywords in C are in |
| A. | Uppercase letters |
| B. | None of these |
| C. | Lowercase Letter |
| D. | Camel Case letters |
| Answer» D. Camel Case letters | |
| 3. |
Which of the following special symbol allowed in a variable name? |
| A. | (underscore) |
| B. | – (hyphen) |
| C. | | (pipeline) |
| D. | * (asterisk) |
| Answer» B. – (hyphen) | |
| 4. |
int **ptr; is? |
| A. | Pointer to integer |
| B. | None of these |
| C. | Pointer to pointer |
| D. | Invalid declaration |
| Answer» D. Invalid declaration | |
| 5. |
In the standard library of C programming language, which of the following header file is designed for basic mathematical operations? |
| A. | conio.h |
| B. | stdio.h |
| C. | math.h |
| D. | dos.h |
| Answer» D. dos.h | |
| 6. |
Which of the following is a collection of different data types? |
| A. | String |
| B. | Structure |
| C. | Array |
| D. | Files |
| Answer» C. Array | |
| 7. |
Strings are character arrays. The last index of it contains the null-terminated character |
| A. | \t |
| B. | \1 |
| C. | \0 |
| D. | \n |
| Answer» D. \n | |
| 8. |
Which of the following uses structure? |
| A. | Linked Lists |
| B. | Array of structures |
| C. | |
| D. | All of these |
| Answer» D. All of these | |
| 9. |
A pointer variable can be |
| A. | Changed within function. |
| B. | Assigned an integer value. |
| C. | None of these |
| D. | Passed to a function as argument |
| Answer» E. | |
| 10. |
Comment on the below while statement while (0 == 0) { } |
| A. | It has syntax error as there are no statements within braces {} |
| B. | It will run forever |
| C. | It compares 0 with 0 and since they are equal it will exit the loop immediately |
| D. | It compares 0 with 0 and since they are equal it will exit the loop immediately |
| Answer» C. It compares 0 with 0 and since they are equal it will exit the loop immediately | |
| 11. |
If a function is defined as static, it means |
| A. | The value returned by the function does not change |
| B. | all the variable declared inside the function automatically will be assigned initial value of zero |
| C. | It should be called only within the same source code/program file. |
| D. | None of the other choices as it is wrong to add static prefix to a function |
| Answer» D. None of the other choices as it is wrong to add static prefix to a function | |
| 12. |
Given the below statements about C programming language; 1) main() function should always be the first function present in a C program file 2) all the elements of an union share their memory location 3) A void pointer can hold address of any type and can be typecasted to any type 4) A static variable hold random junk value if it is not initialised Which of the above are correct statements? |
| A. | 2,3 |
| B. | 1,2 |
| C. | 1,2,3 |
| D. | 1,2,3,4 |
| Answer» D. 1,2,3,4 | |
| 13. |
Which of the following statements about stdout and stderr are true? |
| A. | They both are the same |
| B. | Run time errors are automatically displayed in stderr |
| C. | Both are connected to the screen by default. |
| D. | stdout is line buffered but stderr is unbuffered. |
| Answer» E. | |
| 14. |
Which of the following is true? |
| A. | realloc() can change the memory size of arrays |
| B. | Unary operator works on only one operand |
| C. | Struct and Union works in same way. |
| D. | None of the above |
| Answer» C. Struct and Union works in same way. | |
| 15. |
What is the task of pre-processor? |
| A. | Expanding |
| B. | Compiling |
| C. | Linking |
| D. | All of the above |
| Answer» B. Compiling | |
| 16. |
Which is not a string function? |
| A. | strstr |
| B. | strcmp |
| C. | strupr |
| D. | strchr |
| Answer» D. strchr | |
| 17. |
Which is the character array used to accept command line arguments? |
| A. | char argv |
| B. | char* argv[] |
| C. | char argv[] |
| D. | char* argv |
| Answer» C. char argv[] | |
| 18. |
The name of the variable used in one function cannot be used in another function |
| A. | 1 |
| B. | |
| C. | May be |
| D. | None of the mentioned |
| Answer» C. May be | |
| 19. |
A variable declared in a function can be used in main |
| A. | 1 |
| B. | |
| C. | True if it is declared static |
| D. | None of the mentioned |
| Answer» C. True if it is declared static | |
| 20. |
Which is false ? |
| A. | A variable defined once can be defined again with different scope |
| B. | A single variable cannot be defined with two different types in the same scope |
| C. | A variable must be declared and defined at the same time |
| D. | A variable refers to a location in memory |
| Answer» D. A variable refers to a location in memory | |
| 21. |
How many times the below loop will be executed? #include int main() { int i; for(i=0;i |
| A. | 5 |
| B. | 1 |
| C. | 0 |
| D. | 3 |
| Answer» B. 1 | |
| 22. |
If a function’s return type is not explicitly defined then it’s default to ______ (In C). |
| A. | int |
| B. | float |
| C. | void |
| D. | Error |
| Answer» B. float | |
| 23. |
Select the missing statement? #include long int fact(int n); int main() { \\missing statement } long int fact(int n) { if(n>=1) return n*fact(n-1); else return 1; } |
| A. | printf(“%ll\n”,fact(5)) |
| B. | printf(“%u\n”,fact(5)) |
| C. | printf(“%d\n”,fact(5)) |
| D. | printf(“%ld\n”,fact(5)) |
| Answer» E. | |
| 24. |
Guess the output: main() { printf(“%d”, sizeof(‘a’)); //same as → sizeof(97) } |
| A. | 2 or 4 — |
| B. | 1 or 3 |
| C. | Garbage value |
| D. | ASCII value of a |
| Answer» B. 1 or 3 | |
| 25. |
Predict the output of following code: main() { int a=10,x; x= a– + ++a; printf(“%d”,x); } |
| A. | 19 |
| B. | 20 |
| C. | 22 |
| D. | 23 |
| Answer» C. 22 | |
| 26. |
Choose the correct statement while (0 == 0) { } |
| A. | It has syntax error as there are no statements within braces {} |
| B. | It will run forever |
| C. | It compares 0 with 0 and since they are equal it will exit the loop immediately |
| D. | It has syntax error as the same number is being compared with itself |
| Answer» C. It compares 0 with 0 and since they are equal it will exit the loop immediately | |
| 27. |
Which has the highest precision? |
| A. | float |
| B. | double |
| C. | unsigned long int |
| D. | |
| Answer» C. unsigned long int | |
| 28. |
Which of the following does not require to include math.h header file? |
| A. | pow() |
| B. | rand() |
| C. | sqrt() |
| D. | sinh() |
| Answer» C. sqrt() | |
| 29. |
Which of this is used to skip one iteration: |
| A. | break |
| B. | continue |
| C. | goto |
| D. | return |
| Answer» C. goto | |
| 30. |
Which of the following is not a pointer declaration? |
| A. | char a[10] |
| B. | char a[] = {‘1’, ‘2’, ‘3’, ‘4’} |
| C. | char *str |
| D. | chara |
| Answer» E. | |
| 31. |
Which keyword is used to prevent any changes in the variable within a C program? |
| A. | immutable |
| B. | mutable |
| C. | const |
| D. | volatile |
| Answer» D. volatile | |
| 32. |
Which of the following declaration is illegal? |
| A. | char *str = “Best C programming classes by Sanfoundry” |
| B. | char str[] = “Best C programming classes by Sanfoundry” |
| C. | char str[20] = “Best C programming classes by Sanfoundry" |
| D. | char[] str = “Best C programming classes by Sanfoundry” |
| Answer» E. | |