eee Ue m Omnis tn Gens
for more MCQ
Question: 1. What would be the output of the following program?
ant x=40;
maint
int x=20;
printe¢"
"4D;
>
Option A. 40
Option B. 20
Option C. Compilation Error
Option D. Gaxbeg Value
Question: 2. What will be output if you will compile and execute the following ¢ code?
winclude
ant mainQt
int 4-320;
char *ptr=(char *)&1;
printt("sd", *ptr);
return 0;
y
Option A. 1
Option B. 64
Option ¢. 320
Option D. Compiler Error
Question: 3.
What will be output if you will compile and execute the following c code?
#include
define x 542
ant mainQt
ant 4;
printe("kd" i)
return 0;
>Option A. 27
Option B. 343
Option C, 233
Option D. Compiler Error
Question: 4
What will be output if you will compile and execute the following c code?
#include
int mainOt
char ¢=125;
crcr10;
printf ("kd" ,c);
return @;
>
Option A. 135
Option B. +INF
Option ¢. -121
Option D. -135
Question: 5. What will be output if you will compile and execute the following ¢ code?
winclude
int main¢)
printf ("Equal");
else if(a
Option A. Less than
Option B. Equal
Option ¢
Greater than
Option D. None of aboveQuestion: 6. For 1ébit compiler allowable range for integer constants is _.
Option A. 3.4638 to 3.4e38
Option B. 32767 to 32768
Option C, 32768 to 32767
Option D. 32668 to 32667
Question: 7. C programs are converted into machine Language with the help of
Option A. An Editor
Option B. A compiler
Option C. An operating system
Option D. None of the above
Question: 8. AC variable cannot start with
Option A. An alphabet
Option B. A nunber
Option C. A special symbol other than underscore
Option D. both (b) and Ce)
Question: 9, Which of the following is allowed in a C Arithmetic instruction
Option A. []
Option 8. (}
Option c. ()
Option D. None of the above
Question: 18. Which of the following shows the correct hierarchy of arithmetic operations in C
Option A. / + *
Option B. * / +
Option c. + / *
Option D. * / + =
Question: 11. What is an array?
Option A. An array is @ collection of variables that are of the dissimilar data type
Option B. An array is @ collection of variables that are of the same data type.
Option C. An array is not a collection of variables that are of the same data type
Option D. None of the above
Question: 12. What is right way to Initialization array?
Option A. int nun[6] = { 2, 4, 12, 5, 45, 595
Option B. int n{} = (2, 4, 12, 5, 45,595
Option C. int n{6} = { 2< 4< 12};
Option D. int n(6) = (2, 4, 12, 5, 45, 595Question: 13. An array elements are always stored in _ _ memory Locations.
Option A. Sequential
Option 8. Random
Option C. Sequential and Random
Option D. None of the above
Question: 14. What is the right way to access value of structure variable book{ price, page }?
Option A. print£("d%d", book.price, book.page)
Option B. printf("akd", price.book, page.book)
Option C. print£("Sd¥d"< price: :book< page: :book)
Option D. printf("Sd%d", price>book, page>book)
Question: 15. perror( ) function used to ?
Option A, Work same as printf()
Option B. prints the error message specified by the compiler
Option C. prints the garbage value assigned by the compiler
Option D. None of the above
Question: 16. Bitwise operators can operate upon?
Option A. double and chars
Option B. floats and doubles
Option C. ints and floats
Option D. ints and chars
Question: 17. What is C Tokens?
Option A. The smallest individual units of ¢ program
Option B. The basic element recognized by the compiler
Option C. The Largest individual units of progran
Option D. A & B Both
Question: 18. What is Keywords?
Option A. Keywords have some predefine meanings and these meanings can be changed
Option B. Keywords have some unknown meanings and these meanings cannot be changed.
Option C. Keywords have some predefine meanings and these meanings cannot be changed
Option D. None of the above
Question: 19. If the class name is X, what is the type of its “this” pointer (in a nonstatic, non-
const member function)?
Option A. const X* const
Option B. X* const
Option c. x*
Option D. x&Question
Option
Option
Option
cea @>
Option
Question.
Option
Option
Option
va a>
Option
Question
Option A.
Option B
Option ¢
Option D
Question
Option
Option
Option
caw
Option
Question
Option
Option
Option
cee>
Option
Question.
Option A.
Option B
Option ¢
Option 0
Question
Option
Option
Option
cage
Option
28. Which classes allow primitive types to be accessed as objects?
Storage
Virtual
Friend
Wrapper
21. When is std::bad_alloc exception thrown?
When new operator cannot allocate memory
When alloc function fails
When type requested for new operation is considered bad< thisexception is thrown
When delete operator cannot delete teh allocated (corrupted) object
22. Which one of the following is not a fundamental data type in C++
float
string
int
wehar_t
23. Which of the following is a valid destructor of the class name "Country"
int ~Country()
void Country()
int ~Country(Count
obj)
void ~Country()
24. Which of the following correctly describes C++ Language?
Statically typed Language
Dynamically typed Language
Both Statically and dynamically typed Language
Type-Less Language
25. Which of the following keyword supports dynamic method resolution?
abstract
Virtual
Dynamic
Typeia
26. Which of the following is the most preferred way of throwing and handling exceptions?
Throw by value and catch by reference.
Throw by reference and catch by reference.
Throw by value and catch by value
Throw the pointer value and provide catch for teh pointer typeQuestion
27. Which of the following is not true about preprocessor directives
Option A. They begin with a hash symbol
Option 8. They are processed by a preprocessor
Option C. They form an integral part of the code
Option D. They have to end with a semi colon
Question: 28. What's wrong? while( (i < 18) && (i > 24))
Option A. the Logical operator && cannot be used in a test condition
Option B. the while Loop is an exit-condition Loop
Option C. the test condition is always true
Option D. the test condition is always false
Question: 29. A continue statement causes execution to skip to
Option A. the return 0; statement
Option B. the first statement after the Loop
Option C. the statement following the continue statement
Option D. the next iteration of the Loop
Question: 30. What's wrong? (x= 4 && y = 5)? (a= 5); (= 6)
Option A. the question mark should be an equal sign
Option B. the first semicolon should be a colon
Option C. there are too many variables in the statement
Option D. the conditional operator is only used with apstrings
Question: 31, What's wrong? for (int k = 2, k <=12, KH)
Option A. the increment should always be +#k
Option 8. the variable must always be the letter i when using a for Loop
Option C. there should be a semicolon at the end of the statement
Option D. the conmas should be semicolons
Question: 32. Which of the following is not recommended in a header file?
Option A. Type definitions (typedefs)
Option B. Class definitions
Option C. Function definitions
Option D. Template definitions
Question: 33. Which of the SIL containers store the elements contiguously (in adjecent memory
Locations)?
Option A. std:
Option B. std:
Option ¢, std::map
Option D. std::setQuestion
Option
Option
Option
cea @>
Option
Question.
Option
Option
Option
va a>
Option
Question
Option A
binding
Option B
funetion
Option ¢
binding
Option D
function
Question
Option
Option
Option
cp e>
Option
Question:
Option
Option
Option
cage
Option
Question.
Option A.
Option B
Question
Option A.
Option B
34, Which of the following is not a standard exception built in CH
std: :bad_creat
std: :bad_alloc
std: :bad_cast
std: :bad_typeid
35. What does STL stand for?
Simple Template Library
Standard Template Library
Static Type Library
Single Type-based Library
36, What is the difference between overloaded functions and over:
‘idden functions?
Overloading is a dynamic or run-time binding and Overriding is static or compile-time
Redefining a function in a friend class is called function overriding while Redefining a
in a derived class is called a overloaded fuention
Overloading is a static or compile-time binding and Overriding is dynamic or
Redefining a function in a friend class is called function overloading while
in a derived class is called as overridden fucnion.
37. Which one of the following is not a valid reserved keyword in C++
Explicit
Public
Implicit
Private
38. Each pass through a loop is called a/an
enumeration
iteration
culmination
pass through
39. No conmas or blanks are allowed within an integer or a real constant
True
False
40. void’ is a datatype.
True
False
run-time
Redefining aQuestion
Option A.
Option B
Question.
Option A.
Option B
Question
Option A.
Option 8.
Question.
41. emp name’ is a valid variable name,
True
False
42. unsigned’ is a valid variable name.
True
False
43. Operation between an integer and float always yields a float result
True
False
44, /* The C Language.
/* is a procedural Language .*/*/
The above statement is valid.
Option A.
Option B.
Question
Option A.
Option B
Question
Option A.
Option B
Question
Option A.
Option 8
Question
Option A.
Option B.
Question
Option A.
Option B
Question
True
False
45. The default initial value of automatic storage class is 0
True
False
46
and
have the same operation.
True
False
47. Character data types cannot be declared as unsigned.
True
False
48. && and & operators have the same meaning
True
False
49. Right shifting an operand ibit is equivalent to multiplying it by 2
True
False
5@. The same variable names of automatic type can be used in different functions without
any conflictOption A.
Option 8.
Question
Option A.
Option B.
Question
Option A.
Option B
Question
Option A.
Option B
Question
Option A.
Option B
Question
Option A.
Option B
Question
Option A.
Option B
Question
Option A.
Option B
Question
Option A.
Option 8
Question.
Option A.
Option 8
Question.
True
False
Si. printf("Kd", sizeof('2')); will print 2
True
False
52. The expression "b = 3 * 2;" will evaluate b = 9.
True
False
53. The expression "int i= j = k = @;" is invalid
True
False
54, printf() is not a Library function,
True
False
55. The expression (i + j)++ is illegal
True
False
56. The expression 'int j = 6 + 3 % -9;' evaluates to
True
False
57. pt+ executes faster than p + 1.
True
False
58. static variable will not always have assigned value
True
False
59. Variables declared as register storage type gets stored in CPU registers
True
False
60. Single operations involving entire arrays are permitted in COption A.
Option 8.
Question
Option A.
Option B.
Question
Option A.
Option B
Question
Option A.
Option B
Question
True
False
61. The main() function can be called from any other function
True
False
62. The main() function can call itself recursively.
True
False
63. The statement "for (i = 8, j = 2; j <= 10; j##)" ds a valid statement in 'C
True
False
64. When a user defined function is defined in program, then it has to be called at Least
once from the main()
Option A.
Option B
Question
Option A.
Option B
Question
Option A.
Option B
Question
Option A.
Option 8
Question.
Option A.
Option B.
Question
Option A.
Option B.
Question.
True
False
65. Left shift operator rotates the bits on the Left and places them to the right
True
False
66. A recursive function calls itself again and again.
True
False
67. Only one break can be used in one Loop
True
False
68. Every if statement can be converted into an equivalent switch statement
True
False
69, Nested macros are allowed.
True
False
70. Expression 4**3 evaluates to 64.Option A.
Option 8.
Question
Option A.
Option B.
Question
Option A.
Option B
Question
Option A.
Option B
Question
Option A.
Option B
Question
Option A.
Option B
Question
Option A.
Option B
Question
Option A.
Option B
Question
Option A.
Option 8
Question.
Option A.
Option 8
Question.
True
False
71. ALL macro substitutions in a program are done before compilation of the program
True
False
72. # define PI = 8;' is the correct declaration of macros
True
False
73. An array declar
d as A[100][100] can hold a maximum of 100 eLenents.
True
False
74. The array ‘ch:
name[1@] can consist of a maximum of 9 characters.
True
False
75. It is necessary to initialize the array at the time of declaration
True
False
76. the value *(8i) is same as printing the value of address of i
True
False
77. & pointer is an indication of the variable to be accessed next
True
False
78. The contents of a file opened in ‘r+! mode cannot be changed
True
False
79. Union is used to hold different data at different time
True
False
80. ALL elements of a structure are allocated contiguous memory LocationsOption A.
Option 8.
Question
Option A.
Option B.
Question
Option A.
Option B
Question
Option A.
Option B
Question
Option A.
Option B
Question
Option A.
Option B
Question
Option A.
Option B
Question
Option A.
Option B
Question
Option
Option
Option
sp e>
Option
Question.
Option A.
Option 8
Option ¢
True
False
81. enum helps to create user defined datatype
True
False
82. The value of an enumerated datatype can be read using scanf() function
True
False
83, Structures within structures cannot be created.
True
False
84. gets() and puts() are unformatted 1/0 functions
True
False
85. The identifier argv[] is a pointer to an array of strings
True
False
86. fprintfCfunction can be used to write into console.
True
False
87. fopenC) function returns a pointer to the open file.
True
False
88. Which of the following Language is predecessor to C Programming Language?
rN
8
BCPL
cH
89. programming Language was developed by
Dennis Ritchie
Ken Thompson
Bill GatesOption D
Question.
Option A
option B
Option C
Option D
Question
Option A.
Option B
Option ¢
Option D
Question
Option
Option
Option
cae >
Option
Question.
Option A.
Option 8.
Option c
Option D.
Question
Option
Option
Option
same
Option
Question
Option
Option
Option
cae >
Option
9
Question
Option A.
Option 8.
Peter Norton
98. C is a___ Language
High Level and Procedural
Low Level and OOPS
Middle Level and Procedural
Machine Level. and 00°S
91. Which escape character can be used to beep from speaker in C
\a
\b
\n
92. Which of the following is invalid?
93. A declaration float a, b; occupies ___ of memory
1 byte
4 bytes
8 bytes
16 bytes
94. The print£() function retunes which value when an error occurs
Positive value
Zero
Negative value
None of these
95. Identify the wrong statement
putchar(65)
putchar('x')
putchar("x")
putchar¢
96. Which header file is essential for using stremp() function?
string.h
strings.Option C. text.h
Option D. stremp.h
Question: 97. Which among the following is a unconditional control structure
Option A. do-white
Option B. if-else
Option C. goto
Option D. for
Question: 98. continue statement is used
Option A. to go to the next iteration in a Loop
Option B. come out of @ Loop
Option C. exit and return to the main function
Option D. restarts iterations from beginning of Loop
Question: 99. Which of the following is an example of compounded assignment statement?
Option A. a= 5
Option B. a t= 5
Option C.a=b=c
Option D. a=»
Question: 100. In the expression - 'x + y + 3z
Option A. x + y! is a keyword
Option B. 3 and 20 are constants
Option C. 3z is a constant
Option D. y is a variable and z is a constant
20 Because whenever there is a conflict between a Local and a global variable, it is the
1 8
Local variable gets priority
As we know size of int data type is two byte while char pointer can pointer one byte at
tine,
Memory representation of int 1=320
2 B =
So char pointer ptr is pointing to only first byte as shown above figure.
‘ptr i.e. content of first byte is 01000000 and its decimal value is 64.
As we know define is token pasting preprocessor it only paste the value of micro
constant in the program before the actual compilation start. If you will see intermediatefile you will find:
test.c 1
test.c 2: void main(){
test.c 3: int i;
test.c 4: i=5+2*5+2"S+2;
test.c 5: printf("¥d",i);
test.c 6: }
test.c 7
You can absorb #define only pastes the S+2 in place of x in program. So, i=5+2*5+2"S+2
=5+19+10+2
-27
As we know char data type shows cyclic properties i.e. if you will increase or decrease
the char variables beyond its maximum or minimum value respectively it will repeat same
value according to following cyclic order:
So,
126
127
128
127
126
125
124
125+8+-123
125+9=-122
125+10=-121
5.2 is double constant in c. In c size of double data is 8 byte while a is float
variable. Size of float variable is 4 byte.
So double constant 5.2 is stored in memozy as:10
a
12
13
14
4s
16
17
18
19
28
21
22
23
101.08 11¢@11¢@ 11001190 11001100 110011¢@ 11¢@1100
a1e91101
Content of variable a will store in the memory as
101.00110 @1100110 @1100110
It is clear variable a is Less than double constant 5.2 Since 5.2 is recurring float
number so it different for float and double. Number Likes 4.5,
values in float and double data type
So the answer is (A)
3.25,
5.@ will store same24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
a
42
43
44
45
46
47
48
49
se
st
52
5354
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
n
n
B
74
75
76
7
78
79
80
81
82
8384
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
108