Introduction to Programming
Introduction to Programming
1.
2.
3.
4.
16. When the compiler overload the assignment (=) operator
by default then
1. Class members are not assigned properly
2. Compiler does not allow default assignment operator
3. Compiler does member wise assignment.
4. None of the given
17. The purpose of using cout<< is to ________.
1. Display information on the screen
2. Read the data from keyboard
3. Read the data from a file
4. Write into a file
18. getche() is a ____ function and defined in ____ header file.
1. user-define function , conio.h
2. built-in function , conio.h
3. built-in function, stlib.h
4. built -in function, iostream.h
19. cout << i << " ";
cout << d <<" ";
cout << f;
Above statements can be written within statement of one line
as:
1. cout << i <<" "<< d " "<< f << ;
2. cout << i << << d << << f <<;
3. cout << i <<" "<< d <<" "<< f;
4. cout << i << " "<< d <<" " f<<;
20. The memory allocation functions return a chunk of
memory with a pointer of type ________.
1. integer
2. float
3. ptr
4. void
21. ________ is used as a dereferencing operator.
1. *
2. +
3. -
4. None of the above
22. Which of the following expression is correct in C/C++
language?
1. X = X + 3
2. 3 = X + 3
3. Y + X = 7
4. X + 5 = Y + 7
23. ________ operator is used to pass the address of a variable
in call by reference method.
1. %
2. +
3. @
4. &
24. ________ are not available in C language.
1. User defned functions
2. Built in functions
3. Library functions
4. Inline functions
25. Function prototype is written,
1. Within main function
2. After the return statement in main
3. Before the return statement in main
4. Before call of that function
26. ________ stops execution at the line that contains error(s)
in the code.
1. Compiler
2. Debugger
3. Interpreter
4. Linker
27. Suppose int i = 10; then what is the output of cout<<oct<<i;
1.
10
2.
11
3.
12
4.
13
28. Within the statement obj1=obj2; obj1 will call the
assignment operator function and obj2 will be passed as an
argument to function.
1. True
2. False
29. ________ will explain the function of a program.
1. Comments
2. Debugger
3. Compiler
4. Linker
30. Which of the following is an example of logical operator?
1.&&,||
2.<,>
3.+,*
4./,%
31. We can ________ pointer.
1. increment
2. decrement
3. reassign
4. all of the given
32. ________ operators are the ones that require two operands on
both sides of the operator.
1. Double
2. Tow sided
3. Binary
4. None of the given
33. In C++, which of the following option has the contact meaning
of the expression a <= b"?
1. a is greater than or equal to b
2. a is less than b
3. a is greater than b
4. a is less than or equal to b
34. The dynamic memory allocation uses ________ whereas static
memory allocation uses ________.
1. heap , stack
2. stack , lists
3. array , stack
4. classes , array
35. ________ function gives the position of the next character
to be read from that file.
1. Tell p()
2. tell g()
3. seek g()
4. seek p()
36. Here the code is given below. You have to identify the
problem in the code.
while(i < 10) && (i > 24))
1. the logical operator && cannot be used in test condition
2. the while loop is an exit-condition loop
3. the test condition is always true
4. the test condition is always false
37. To access the data members of structure, ________ is used.
1. Logical operator
2. Dereference operator
3. Dot operator
4. Address operator
38. Which one of the given option is not a mode for
reading/writing the data from a file?
1. in
2. out
3. trunc
4. get
39. What will be the result of the expression k = ++m; if
initially k = 0 and m = 4?
1. 0
2. 5
3. 6
4. 4
40. If a function has been declared but not defined before its
function call then it is termed as ________.
1. logical error
2. syntax error
3. run time error
4. program time error
41. If B is designated as friend of A, B can access A's non-
public members.
1. B cannot access private member of A
2. B cannot access protected member of A
3. A can access non-public members of B
4. A cannot access B
42. Symbolic constant PI can be defined as:
1. #define PI 3.14;
2. #define PI 3.14
3. #define PI=3.14
4. # include pi=3.14
43. ___ will return the number of bytes reserved for a
variable or data type.
1. sizeof operator
2. free operator
3. void pointer
4. new operator
44. While programming, it is good to provide an easy to
understand and easy to use interface; this programming skill
is called ____.
1. scalability
2. usability
3. reliability
4. sustainability
45. To avoid dangling reference, don't return ________.
1. the reference of a local variable from the function
2. the reference of a global variable from the function
3. the reference of a static variable from the function
4. the reference of a private data member from the function
46. Syntax of a union is identical to ________.
1. structure
2. class
3. function
4. loop
47. dec, hex, oct are all ________.
1. Member functions
2. Objects of input/output streams
3. Parameterized manipulators
4. Non-parameterized manipulators
48. The ________ is called automatically when an object
destroys.
1. destructor
2. constructor
3. main program
4. default constructor
79. How many bytes an integer type pointer intPtr will jump
in memory if the statement below is executed?
intPtr += 2 ;
1. 2
2. 4
3. 8
4. 12
80. We cannot use ________ pointer for storing and reading
data from it.
1. 'NULL
2. integer
3. double
4. zero
81. When an array element is passed to a function, it is
passed by ________.
1. reference
2. data type
3. value
4. data
82. The members of a class declared with the keyword struct
are ________ by default.
1. static
2. Private
3. protected
4. public
83. In C/C++, the default command line arguments passed to
the main function are ________.
1. float argc, char **argv
2. int argc, char **argv
3. int *argc, char *argv
4. int argc, float **argv
84. What will be the result of the expression j = i++; if
initially j = 0 and i = 5?
1. 0
2. 5
3. 6
4. 4
85. Symbolic constant PI can be defined as:
1. #define PI 3.14 ;
2. #define PI 3.14
3. #define PI=3.14
4. # include pi= 3.14
86. char **argv can be read as ________.
1. pointer to pointer
2. pointer to char
3. pointer to pointer to char
4. None of the given
87. The compiler of C language is written in ________
language.
1. JAVA
2. BASIC
3. FORTRAN
4. C
88. !( x < 3) means in C++ that
1. x is less than 3
2. x is greater than or equal to 3
3. x is greater than 3
4. x is equal to 3
89. A 2D array multi[5][10] can be accessed using the
array name as **multi, this technique is called ________.
1. Single referencing
2. Single dereferencing
3. Double referencing
4. Double dereferencing
90. Overloaded assignment operator must be
1. Member function of class
2. Non-member function of class
3. Friend function of class
4. Global function
91. We want to access array in random order which of
the following approach is better?
1. Pointer
2. Array index
3. Both pointers and array index are better
4. Matrix
92. The name of the destructor is the same as that of a
class proceeding with a ________.
1. & sign
2. # sign
3. @ sign
4. ~ sign
int i = 1;
while(i<10){
if(i%2 == 0)
cout<<i<<" ";
i++;}
1. 2 4 6 10
2. 1 3 5 7
3. 2 4 6 8
4. 2 4 8 10
119. It is possible to return an object from function using this
pointer.
1. True
2. False
120. In C++, a variable can be declared anywhere in the
program this will increase ________.
1. writability
2. readability
3. portability
4. efficiency
121. Suppose that an integer type pointer contains a memory
address 0x22f230. What will be the new memory address if we
increment this pointer by one?
1. 0x22f231
2. 0x22f234
3. 0x22f226
4. 0x22f238
122. Learning "how to program" is important, because it
develops ________ and problem-solving abilities.
1. Analytical
2. Writing
3. Listening
4. Reading
123. Which of the following is the starting index of an array in
C++?
1. 0
2. 1
3. -1
4. 2
124. From the options given, you need to choose the option
which is true for the given code.
double output = 0;
output = (2 + 2) * 4 + 2 / (4 - 2);
1. 15
2. 17
3. 12
4. 11
181. ________ operators are the ones that require only one
operator to work.
1. Unit
2. Unary
3. Single
4. None of the given
182. What will be the correct syntax for initialization of a pointer
ptr with string "programming"?
1. char ptr = 'programming';
2. char *ptr = "programming";
3. char *ptr = 'programming';
4. *ptr = "programming";
183. if
int sum = 54;
Then the value of the following statement is
sum = sum - 3;
1. 52
2. 50
3. 51
4. 57
184. What is the function of the following statement to delete
an array of 5 objects named 'arr' allocated using new operator?
delete arr;
1. Results into syntax error
2. Deletes all the objects of array
3. Do not delete any object
4. Deletes only one object of array
185. We should use ________ for clarity and to force the order of
evaluation in an expression.
1. brackets []
2. parenthesis ()
3. curly braces {}
4. quotation marks " "
186. Which one of the following is mandatory preprocessor
directive for c++?
1. #undef
2. #include
3. #undef
4. All of the given
187. It is the job of ________ to transfer the executable code from
hard disk to main memory.
1. interpreter
2. Debugger
3. Linker
4. Loader
188. A reference cannot be NULL it has to point a data type.
1. True
2. False
189. The coding of a program is translated into machine
language by ________.
1. Debugger
2. Compiler
3. Loader
4. Linker
190. Overloading means :
1. Using the same name to perform multiple tasks or different
tasks depending on the situation.
2. Using the different name to perform multiple tasks or different
tasks depending on the situation
3. Using the same name to perform multiple tasks or same tasks
depending on the situation
4. Using the same name to perform difficult tasks or complex tasks
and it does not depend on the situation
191. You cannot overload the ________ operator.
1. ? :
2. *
3. /
4. ++
192. !( x > 3) means in C++ that
1. x is greater than 3
2. x is less than or equal to 3
3. x is less than 3
4. x is equal to 3
193. What is the output of the following code if the 2nd case
is true
switch (var) {
case 'a': cout<<"apple"<<endl;
case 'b':cout<<"banana"<<endl;
case 'm':cout<<"mango"<<endl;
default: cout<<"any fruit"<<endl;}
1. banana
2. banana any fruit
3. banana mango any fruit
4. None of the given
194. ________ will be used for enclosing function
statements into a block.
1. " "
2. ()
3. []
4. {}
195. Operating System is a type of a/an ________.
1. application software
2. system software
3. computer language
4. interpreter
196. The second parameter of operator function for >>
operator must always be passed
1. By reference
2. Function takes no argument
3. By value
4. None of the given
197. What will be the result of arithmetic expression
6+48/4*3?
1. 10
2. 40.5
3. 42
4. 41
198. We should not use such variable names that are starting
with ________ because in C++, there are lots of internal
constants and symbolic names that start with it.
1. upper case alphabets
2. lower case alphabets
3. double underscore
4. None of the given
199. != operator is used to check whether the operand on the
left-hand-side is _____ to the operand on the right-hand-side.
1. Less than or equal
2. Greater than or equal
3. Not equal
4. Approximately equal to
200. The statement cout << yptr will show the ________ the
yptr points to.
1. Value
2. memory address
3. variable
4. None of the given
201. Whenever some number is added in an array name, it
will jump as many ________ as the added number.
1. rows
2. value
3. column
4. bytes
202. Structure use ________ allocation.
1. Queue
2. Heap
3. Cache
4. Stack
203. Which of the following operators is used to access the
value of variable pointed by a pointer?
1. * operator
2. -> operator
3. && operator
4. & operator
204. In C/C++, the algebraic expression (b2-4ac) / 2a can be
written as:
1. (b*b - 4*a*c) / (2*a)
2. b*b - 4*a*c / (2*a)
3. b*b - 4*a*c / 2*a
4. b*b - (4*a*c) / 2*a
205. In case of single dereferencing, the value of the ________
is the address of the ________.
1. pointer, variable
2. pointer, constant
3. variable, pointer
4. constant, pointer
206. The operators ++ and -- are used to increment or
decrement the value of a variable by ________.
1. 3
2. 2
3. 1
4. 4
207. Both compiler and ________ are used to translate program
into machine language code.
1. debugger
2. linker
3. loader
4. interpreter
208. C/C++ has many libraries which contain variables and
function names normally starting with ________.
1. Hyphen
2. Hash
3. Underscore
4. emi-Colon
209. How many times the following loop will execute?
int j = 3; while(j > 0) { cout << "Statements" << endl; j -= 2; }
1. 0
2. 1
3. 2
4. 3
210. ostream class is ________ and not under our control.
1. user-defined
2. built-in
3. both user-defined and built-in
4. None of the given
211. In C/C++, which of the following data type is used to
store real numbers?
1. float
2. char
3. boolean
4. int
212. Select the correct way to assign the address of first
element of array to pointer?
1. int *ptr = &data[1];
2. int *ptr = &data;
3. int *ptr = data;
4. int *ptr = data[0];
213. What is the correct syntax to declare an array of size 10
of int data type?
1. int [10] name;
2. name[10] int;
3. int name[10];
4. int name[];
214. The ________ statement allows us to select from multiple
choices based on a set of fixed values for a given expression.
1. switch
2. break
3. continue
4. goto
215. The malloc function takes ________ argument(s).
1. two
2. three
3. four
4. one
216. What will be the output of the given code?
#include #define MAX( A, B ) ((A) > (B) ? (A) : (B))
void main() {
int i, x, y;
x = 23;
y = 45;
i = MAX( x++, y++ );
// Side-effect: // larger value incremented twice
cout << "x = " << x << " y = " << y << '\n';}
1. x=23 y=45
2. x=24 y=46
3. x=24 y=47
4. x=22 y=47
217. Which one of the following languages has been used to
write the compiler of "C" language?
1. Java
2. Fortran
3. Basic
4. C
218. The memory address of the first element of an array is
called ________.
1. floor address
2. foundation address
3. first address
4. base address
219. Which of the following function call is "call by reference"
for the following function prototype?
1. func(int &num);
2. func(&num);
3. func(*num);
4. func(num);
220. C++ views each file as a sequential stream of ________.
1. Bits
2. Bytes
3. Numbers
4. Words
221. The memory allocation in C++ is carried out with the help of .
1. NULL pointer
2. new operator
3. dot operator
4. + operator
int i = 0;
while(i!=15){
cout<<i<<" ";
i = i + 5; }
1. 1 5 10
2. 5 10
3. 0 5
4. 0 5 10
236. Suppose that an integer type pointer contains a memory
address 0x22f220. What will be the new memory address if we
increment this pointer by one?
1. 0x22f221
2. 0x22f222
3. 0x22f223
4. 0x22f224
237. When the logical operator AND (&&) combines two
expressions exp1 and exp2 then the result will be true only __.
1. When both exp1 and exp2 are true
2. When both exp1 and exp2 are false
3. When exp1 is true and exp2 is false
4. When exp1 is false and exp2 is true
238. ________ is a substitute of multiple if statement.
1. if. . .elseif statement
2. Continue statement
3. Break statement
4. Default statement
239. For binary member operators, operands on the ________
drives (calls) the operation.
1. Left
2. Right
3. Both left and right
4. None of the given
240. ____ variables are those that are defined outside of main.
1. Local
2. Dynamic
3. Global
4. Static
255. ________ executes all the lines before error and stops at
the line which contains the error.
1. Intrepreter
2. Compiler
3. Linker
4. Debugger
256. Which of the following is the correct syntax to access the
value of first element of an array using pointer ptr?
1. ptr[0]
2. *(ptr+1)
3. ptr[1]
4. *ptr[0]