MCQOPTIONS
Saved Bookmarks
This section includes 98 Mcqs, each offering curated multiple-choice questions to sharpen your C Programming knowledge and support exam preparation. Choose a topic below to get started.
| 51. |
What will be the n in the following C code?#include <stdio.h> void main() { int n; } |
| A. | static variable |
| B. | global variable |
| C. | automatic variable |
| D. | register variable |
| E. | None of these |
| Answer» D. register variable | |
| 52. |
What will be the output of the following C code? #include <stdio.h> int main() { register int n = 110; int *ptr = &n; *ptr = 111; printf("%d %d n", n, *ptr); } |
| A. | 110 111 |
| B. | 111 110 |
| C. | 111 |
| D. | 110 |
| E. | Compilation Error |
| Answer» F. | |
| 53. |
What will be the output of the following C code?#include <stdio.h> void main() { register int P = 50; function(); printf("P is %d", P); } void function() { P++; } |
| A. | 51 |
| B. | Garbage value |
| C. | Compilation Error |
| D. | 50 |
| E. | None of these |
| Answer» D. 50 | |
| 54. |
What will be the output of the following C code?#include <stdio.h> double p; int main() { printf("%g n",p); return 0; } |
| A. | 0.000000 |
| B. | Garbage value |
| C. | Depend on compiler |
| D. | 0 |
| E. | None of these |
| Answer» E. None of these | |
| 55. |
What will be the output of the following C code?#include <stdio.h> double n = 10; int main() { int n = 6; printf("%d", n); } |
| A. | Compilation Error |
| B. | Runtime Error |
| C. | 6 |
| D. | 10 |
| E. | None of these |
| Answer» D. 10 | |
| 56. |
What will be the output of the following C code? #include <stdio.h> int main() { printf("%d", num++); } int num = 15; |
| A. | 15 |
| B. | Garbage value |
| C. | Runtime Error |
| D. | Compilation Error |
| E. | None of these |
| Answer» E. None of these | |
| 57. |
What will be the output of the following C code?#include <stdio.h> int *p; int main() { if (p == 0) printf("Hey n"); return 0; } |
| A. | Hey |
| B. | Compilation Error |
| C. | Hey only if NULL value is 0 |
| D. | Nothing |
| E. | None of these |
| Answer» D. Nothing | |
| 58. |
What will be the output of the following C code?#include <stdio.h> int *ptr; int main() { if (ptr == NULL) printf("Right n"); return 0; } |
| A. | Right only if NULL value is 0 |
| B. | Compilation Error |
| C. | Nothing |
| D. | Right |
| E. | None of these |
| Answer» E. None of these | |
| 59. |
Can variable p be accessed by functions in another source file?#include <stdio.h> int p; int main() { printf("%d n", p); } |
| A. | No |
| B. | Yes |
| C. | Depends on the type of the variable |
| D. | Only if static keyword is used |
| E. | None of these |
| Answer» C. Depends on the type of the variable | |
| 60. |
What will be the output of the following C code? #include <stdio.h> static int var = 15; void main() { var = 19; { int var = 14; } printf("%d", var); } |
| A. | 15 |
| B. | 14 |
| C. | 19 |
| D. | Compilation Error |
| E. | None of these |
| Answer» D. Compilation Error | |
| 61. |
What will be the output of the following C code?#include <stdio.h> int main() { int p = 200; int p = 17; printf("Hello Interview Mania! %d n", p); return 0; } |
| A. | Interview Mania |
| B. | Hello Interview Mania! |
| C. | Compilation Error |
| D. | Runtime Error |
| E. | None of these |
| Answer» D. Runtime Error | |
| 62. |
What will be the output of the following C code?#include <stdio.h> int main() { printf("Hello Interview Mania! %d n", num); return 0; } |
| A. | Hello Interview Mania! num |
| B. | Compilation Error |
| C. | Hello Interview Mania! |
| D. | Hello Interview Mania! followed by a garbage value |
| E. | None of these |
| Answer» C. Hello Interview Mania! | |
| 63. |
What would be the output of following program ? |
| A. | Error |
| B. | 15 |
| C. | 60 |
| D. | Garbage value |
| Answer» D. Garbage value | |
| 64. |
What will be the output of the following C code if these two files namely sample.c and sample1.c are linked and run? |
| A. | 0 0 |
| B. | 0 12 |
| C. | 12 0 |
| D. | 12 12 |
| E. | None of these |
| Answer» D. 12 12 | |
| 65. |
Automatic variables are allocated space in the form of a __________. |
| A. | random |
| B. | priority queue |
| C. | queue |
| D. | stack |
| E. | None of these |
| Answer» E. None of these | |
| 66. |
Automatic variables are _________. |
| A. | Declared within the keyword extern |
| B. | Declared with auto keyword |
| C. | Declared outside all functions |
| D. | Declared within the scope of a block, usually a function |
| E. | None of these |
| Answer» E. None of these | |
| 67. |
A local variable declaration with no storage class specified is by default ____ |
| A. | register |
| B. | static |
| C. | auto |
| D. | extern |
| E. | None of these |
| Answer» D. extern | |
| 68. |
Automatic variables are initialized to ___________. |
| A. | Nothing |
| B. | Zero |
| C. | Junk value |
| D. | Both Zero & Junk value |
| E. | None of these |
| Answer» D. Both Zero & Junk value | |
| 69. |
Which of the following correctly represents a long double constant ? |
| A. | 2.29 |
| B. | 2.29L |
| C. | 2.29f |
| D. | 2.29LF |
| Answer» C. 2.29f | |
| 70. |
Which of the following statement should be used to obtain a remainder after dividing 7.39 by 5.9 ? |
| A. | rem = 7.39 % 5.9; |
| B. | rem = modf(7.39, 5.9); |
| C. | rem = fmod(7.39, 5.9): |
| D. | rem = 7.39 mod 5.9 |
| E. | We cannot obtain the remainder in floating point division. |
| Answer» F. | |
| 71. |
What will be the n in the following C code? |
| A. | static variable |
| B. | global variable |
| C. | automatic variable |
| D. | register variable |
| E. | None of these |
| Answer» D. register variable | |
| 72. |
What is the format identifier for static num = 200.05; ? |
| A. | Illegal declaration due to absence of data type |
| B. | %s |
| C. | %d |
| D. | %f |
| E. | None of these |
| Answer» D. %f | |
| 73. |
Automatic variables are allocated memory in ___________. |
| A. | Data segment |
| B. | Code segment |
| C. | stack |
| D. | heap |
| E. | None of these |
| Answer» D. heap | |
| 74. |
Register variables reside in ________. |
| A. | main memory |
| B. | stack |
| C. | registers |
| D. | heap |
| E. | None of these |
| Answer» D. heap | |
| 75. |
Automatic variables are stored in ________. |
| A. | heap |
| B. | stack |
| C. | data segment |
| D. | register |
| E. | None of these |
| Answer» C. data segment | |
| 76. |
Which among the following is wrong for register int n; ? |
| A. | You cannot take the address of this variable |
| B. | Access time to a is critical |
| C. | Compiler generally ignores the request |
| D. | All of above |
| E. | None of these |
| Answer» F. | |
| 77. |
Which of the following is not a user-defined data type ? |
| A. | <pre class="prettyprint lang-c">struct employ<br>{<br> char name[10];<br> float salary;<br> int workingdays;<br>};<br></pre> |
| B. | <pre class="prettyprint lang-c">long int k = 65.5;</pre> |
| C. | <pre class="prettyprint lang-c">enum day {Sun, Mon, Tue, Wed};</pre> |
| D. | <pre class="prettyprint lang-c">union xyz<br>{<br> int k;<br> char ch[5];<br>};<br></pre> |
| Answer» C. <pre class="prettyprint lang-c">enum day {Sun, Mon, Tue, Wed};</pre> | |
| 78. |
Which of the following special symbol is allowed in a variable name ? |
| A. | * (star) |
| B. | |(vertical line) |
| C. | - (dash) |
| D. | _ (underscore) |
| Answer» E. | |
| 79. |
Which of the following definition is correct ? |
| A. | int length ; |
| B. | char int ; |
| C. | int long ; |
| D. | float double ; |
| Answer» B. char int ; | |
| 80. |
Which of the following operations are INCORRECT ? |
| A. | <pre class="prettyprint lang-c">int a = 15; a = a%5;<br></pre> |
| B. | <pre class="prettyprint lang-c">short int b = 53; b = b%15;<br></pre> |
| C. | <pre class="prettyprint lang-c">long int c = 125L; c = c % 14;<br></pre> |
| D. | <pre class="prettyprint lang-c">float d = 6.128; d = d%7;<br></pre> |
| Answer» E. | |
| 81. |
Which part of the program address space is p stored in the following C code? |
| A. | Data segment |
| B. | Code/text segment |
| C. | Stack |
| D. | Bss segment |
| Answer» E. | |
| 82. |
Which part of the program address space is ptr stored in the following C code? |
| A. | 0 |
| B. | Code/text segment |
| C. | Data segment |
| D. | Bss segment |
| E. | Stack |
| Answer» D. Bss segment | |
| 83. |
Can variable p be accessed by functions in another source file? |
| A. | No |
| B. | Yes |
| C. | Depends on the type of the variable |
| D. | Only if static keyword is used |
| E. | None of these |
| Answer» C. Depends on the type of the variable | |
| 84. |
Property of the external variable to be accessed by any source file is called by the C90 standard as __________. |
| A. | global linkage |
| B. | global scope |
| C. | external scope |
| D. | external linkage |
| E. | None of these |
| Answer» E. None of these | |
| 85. |
What will be the output of the following C code (after linking to source file having definition of arrayA)? |
| A. | Compile time error due to multiple definitio |
| B. | Compile time error because size of array is not provided |
| C. | Compile time error because datatype of array is not provided |
| D. | Value of arrayA[0]; |
| E. | None of these |
| Answer» D. Value of arrayA[0]; | |
| 86. |
What will be the output of the following C code (without linking the source file in which arrayA is defined)? |
| A. | Linking error due to undefined reference |
| B. | Compile time error because datatype of array is not provided |
| C. | Compile time error because size of array is not provided |
| D. | Interview Mania |
| E. | None of these |
| Answer» E. None of these | |
| 87. |
What will be the sequence of allocation and deletion of variables in the following C code? |
| A. | var->num, num->var |
| B. | var->num, var->num |
| C. | num->var, var->num |
| D. | num->var, num->var |
| E. | None of these |
| Answer» D. num->var, num->var | |
| 88. |
Comment on the following 2 C Example programs. |
| A. | Scope of r is till the end of the main function in Example 2 |
| B. | In Example 1, variables p, q and r can be used anywhere in main function whereas in Example 2, variables q and r can be used only inside their respective blocks. |
| C. | Both are same |
| D. | Scope of p, q and r is till the end of the main function in Example 2. |
| E. | None of these |
| Answer» C. Both are same | |
| 89. |
Which variable has the longest scope in the following C code? |
| A. | p |
| B. | q |
| C. | r |
| D. | both p and r |
| E. | None of these |
| Answer» B. q | |
| 90. |
Variable name resolution (number of significant characters for the uniqueness of variable) depends on ___________. |
| A. | Assemblers and loaders implementations |
| B. | C language |
| C. | Compiler and linker implementations |
| D. | All of above |
| E. | None of these |
| Answer» D. All of above | |
| 91. |
All keywords in C are in ____________. |
| A. | CamelCase letters |
| B. | LowerCase letters |
| C. | UpperCase letters |
| D. | All of above |
| E. | None of these |
| Answer» C. UpperCase letters | |
| 92. |
What is the problem in following variable declaration? |
| A. | The special character - |
| B. | The special character ? |
| C. | The variable name begins with an integer |
| D. | All of above |
| E. | None of these |
| Answer» E. None of these | |
| 93. |
What will happen if the following C code is executed? |
| A. | 10 |
| B. | 12 |
| C. | 15 |
| D. | Compilation Error |
| E. | None of these |
| Answer» D. Compilation Error | |
| 94. |
Will the following C code compile without any error? |
| A. | No |
| B. | Yes |
| C. | Garbage value |
| D. | Depends on the C standard implemented by compilers |
| E. | None of these |
| Answer» E. None of these | |
| 95. |
Global variables are ____________. |
| A. | External |
| B. | Internal |
| C. | Both External and Internal |
| D. | All of above |
| E. | None of these |
| Answer» B. Internal | |
| 96. |
Which of the following is an external variable in the following C code? |
| A. | p |
| B. | q |
| C. | r |
| D. | s |
| E. | None of these |
| Answer» E. None of these | |
| 97. |
Functions in C are always _________. |
| A. | External and Internal are not valid terms for functions |
| B. | Internal |
| C. | External |
| D. | Both Internal and External |
| E. | None of these |
| Answer» D. Both Internal and External | |
| 98. |
Which of the following format identifier can never be used for the variable var? |
| A. | %s |
| B. | %c |
| C. | %d |
| D. | %f |
| E. | None of these |
| Answer» E. None of these | |