Vu All Subjects Assignment Quiz GDB Handouts Available here
1. Aslam U Alaikum!
It is to informed you that Quiz No 3 of CS201 course has been
scheduled and it will open on 27th January, 2023 (12:00 AM) and close on 29th January, 2023 (11:59 PM). Quiz will be from Lectures 32 to 38.
Carefully read instructions before taking quiz. There is no rescheduling of quiz, so take your quiz on time and in starting dates to avoid load on website at ending time.
Quiz No 3 will be opened from
We cannot define friends for the _______________ that are already written and not in our control.
classes
C++ offers type-safe I/O. The << and >> operators are overloaded to accept data items of specific types.
t
Let suppose
int a, b, c, d, e;
a = b = c = d = e = 42;
This can be interpreted by the complier as
a = (b = (c = (d = (e = 42))));
Static data members of a class can be ____________.
public
Overloaded delete operator function takes parameter of void pointer and returns.
void (nothing)
What will be the output of the following code segment? float pi=32.3996; cout<<fixed; cout << setprecision (2) << pi ;
32.39
What will be the output of the following code segment?
int
n=8;
cout<<oct<<n;
8
Below is given a code snippet
char name[50];
cin>>name;
cout<<name;
Now if user enters the name, for example “Sohail Aslam” than
what will be the output of the code ?
Sohail Aslam
When we use cin stream to read some number from the keyboard
and store it in the integer variable, then what will happen?
Its binary representation will be ignored and the value
will be stored
Which of the following is a destination of cout stream?
characters determined by the environment
What is meant by the following statement?.
String str[5] = {String(“Programming”), String(“CS201”)};
Parameterized constructor will be called for all objects
of array
ostream is a _______________ operator.
Standalone
The stream-insertion operator is >> and the
stream-extraction operator is <<.
T
Friend function are used in cases where one class is ____ to another class
Independent
2. For casting, we normally declare a pointer of type ____________.
We are going to use…….confirm
3. Constructor is special type of function
Which has no return type…..confirm from net
4. Class can be defined as
A class includes both objects and structures
5. The object code of our program is combined with the _________.
Object code of the library function….confirm
6. I+=2 is equivalent to ________.
I= i+2….confirm
7. For accessing data members we use _____________ operator.
(Dot.)….confirm
8. The _________ is called automatically when an object destroys
destructor
9. The function overloading requires _______.
The argument list to be the same….confirm
10. With user data type variables (objects) self assignment can produce
Logical error……confirm from net
11. Constructor is a special type of function
Which has no return type……confirm from net
12. Look at the statement given below int & a; and tell what will happen
Compiler will generate an error: a declared as reference but not initialized….confirm from net
13. Macros are categorized into ___________type(s)
Two…..confrim
14. If the memory in the free store is not sufficient ____________.
Malloc function returns NULL pointer…confirm from net
15. A reference cannot be Null it has to point a data type
True…..confirm
16. The friend function of a class can have access __________.
To the private data members….confirm
17. #define CIRCUMFERENCE(X) (2*PI*R) is a.
Definition of a macro…..confirm from net
18. Which of the following is unary operator
i--, i++, ++i…..all options…confirm
19. For overloading a void type pointer ptr into integer type, the correct syntax is
(int*)ptr……confirm
20. Ternary operator is shown as ___________.
?;
21. If we do not write our own assignment operator then which of the following problem may occur?
Dangling pointer
22. Getche() is a __________ function and defined in _________ header file.
Built in function, conio.h……confirm from net
23. Core must be taken about the correct _________ of operator while overloading.
Both semantic and complexity
24. Which function is used to delete the allocated memory space?
Free()……confirm from net
25. Friend functions are ________.
Private……confirm
26. Which one of the following is the correct statement about operator overloading?
Arithmetic operators can be overloaded only
27. Once we have defined a symbolic constant value using #define, that value ______ during program execution.
Cannot be changed……confirm from net
28. Consider the following code segment. Which of the following will be called while executing code at line 2? String s1, s2; s1 = s2
Assignment Operator
29. The concept of _______ allows us to separate the interface from the implementation of the class.
Encapsulation…….confirm
30. In overloading the assignment (=) operator, which object will be passed as an argument(s) in the operator function?
Left object of the assignment operator
31. In overloading the assignment (=) operator, which object(s) will call operator function?
Left object of the assignment……confirm from net
32. Class can be defined as:
A class includes both data members as well as functions to manipulate that data
33. Constructor has ________.
The same name as of class…….confirm
34. We can _________ pointer
Reassign, decrement, increment…….All options correct
35. The constructor contains ____________.
No return type
36. ____________ will return the number of bytes reserved for a variable or data type
Sizeof operator…….confirm from net
37. In C++ the region of available memory is called __________.
Free store
38. The only operator that the compiler overloads for user define data type by default is
Assignment (=) operator….confirm from net
39. Functions declared with the _______________ specifier in a class member list are called friend functions of that class.
friend
40. Public or private keywords can be ____________
written multiple times in the class or structure declaration
41. The friend keyword provides access _____________.
in one direction only
References cannot be uninitialized. Because it is impossible to _______________
reinitialize a reference
42. new operator can be used for ______________.
integer , float, char and double data types……confirm
10. The destructor is used to ______________.
deallocate memory
43. Reference is not really an address it is ______________.
a synonym
44. If we want to allocate memory to an array of 5 integers dynamically, the syntax will be _____________.
int *iptr ; iptr = new int[5] ;
45. Memory allocated from heap or free store _____________________.
cannot be returned back unless freed explicitly using free and delete operators
46. Operator overloading is to allow the same operator to be bound to more than one implementation, depending on the types of the _________.
Operands
47. The operator to free the allocated memory using new operator is ________________.
delete
48. Public or private keywords can be _________.
written multiple times in the class or structure declaration …….confirm from net
49. A class can be declared as a ____________ of other class
Friend class…..confirm
50. In C++ operators, which of the following operator cannot be overloaded __________.
?;
51. We can _________ references.
None of the given options…..confirm from net
52. Being a concise language, C needs something for its __________.
Enhancement…..confirm
53. The compiler gets the modified ______________
source code file…..confirm
54. When we write __________ this somefile is ordinary text file of C code.
#include….confirm
55. The line where we write the ________ statement is replaced by the text of that file.
#include…..confirm
56. All of the preprocessor directives start with __________.
# sign……confirm
57. There are _______ ways to use #include.
Two……confirm
58. ‘h’ stands for ________
header files…..confirm
59. We can include files anywhere in the code but it needs to be _______and at the ___________.
Logical, proper position…….confirm
60. The _________of function must be declared before its usage
Prototype…..confirm
61. The ___________ of compilation will be successful.
first parse…..confirm
62. After the _______ of the compiler, it converts the source code into object code
First phase…..confirm
63. ___________ is machine code but is not re-locateable executable.
Object code……confirm
64. The __________ of our program is combined with the object code of the library functions.
object code……confirm
65. The __________ performs this task while the compiler includes the name and arguments.
Linker…..confirm
66. For checking the _______ of the functions, the compiler needs to know the definition of the function or at least the prototype of the function.
Validity…….confirm
67. The preprocessor will search for the file “myHeaderFile.h” in the current working directory. It will be written as
#include “myHeaderFile.h……confirm
68. ______ is a universal constant and has a value of _______.
Pi, 3.1415926…….confirm
69. Be sure that the value of_________ can not be changed.
Pi……confirm
70. All the preprocessor directives start with the sharp sign.
(#)…….confirm
71. Macros are classified into ______ categories.
Two……confirm
72. The first type of macros can be written using ___________.
#define…….confirm
73. The second type of macros takes arguments. It is also called a _________.
parameterized macros…….confirm
74. Being a _______, it does not require any semicolon at the end.
non-C code…..confirm
75. The__________ will be replaced by the actual macro definition including the entire parenthesis in the code before compilation.
CIRCLEAREA……..confirm
76. A symbol cannot be redefined without________ it first.
Undefining…….confirm
77. The __________ directives help in debugging the program
Conditional compilation……confirm
78. _______ variable names starting with underscore.
Do not declare……confirm
79. Always use _________ while defining macros that takes arguments.
Parenthesis……confirm
80. So an ordinary _______ is actually a C code.
English poem…….confirm
81. Earlier, whenever we declared arrays, the size of the arrays was_________.
Predefined…..confirm
82. It is better to compare both the ________ and ______ allocation methods to understand the benefits of the usage of dynamic memory allocation.
Static , dynamic……..confirm
83. Static allocation is also called _______
Compile time allocation…..confirm
84. A pointer ptr of type void is declared as under
void *ptr ;…..confirm
85. The syntax of the calloc function is as follows.
void *calloc (size_t n, size_t el_size)……confirm
86. The ______ function takes one argument i.e. the number of bytes to be allocated
Malloc……confirm
87. The syntax of the malloc function is as follows
void * malloc (size_t size) ;…..confirm
88. #undef is used for
Making a symbol undefined…..confirm
89. Let suppose a = b = c. In such situation, it is necessary to return a reference of an object from assignment operator function.
True
90. Which one of the following is the declaration of overloaded pre-increment operator implemented as member function?
Class-name operator ++()…..confirm
91. A class is a user defined data type it takes _________.
No space in memory unless we create an object from it……..confirm
92. The heap memory structure __________.
Constantly changes in size…….confirm
93. Which of the following permits function overloading in C++
Both type and arguments……confirm from net
94. The data members of the class are initialized ________.
At runtime…..confirm
95. ___________ operators are the ones that require two operands on both sides of the operator.
Binary……confirm
96. _________ operators are the ones that require only one operator to work to the left of the operand
Unary……..confirm
97. Which one of the following is mandatory preprocessor directive for c++?
#include <iostream>……confirm from net
98. Functions declared with the _________ specifier in a class member list are called friend functions of that class
Friend
99. Default constructor takes _________.
No parameters…..confirm
100. The members of a class declared without any keyword are _____ by default
Private…….confirm from net
101. In a class we can have ______ constructor(s).
Many…..confirm
102. _________ for parameters is also done for inline functions.
Automatic type checking…..confirm
103. An address is a ______, while a pointer is a ___________.
Constant, Variable …… confirm from net
104. The compiler generates _________ automatically
Constructors
105. When an operator function is defined as member function for a binary Plus (+) operator then the number of extra arguments it takes is/are
Two….confirm from net
106. Date+=1 is equivalent to _________.
Date + 1 ……confirm
107. Windows operating system may itself takes memory from __________.
Heap….confirm from net
108. Identify the correct method of adding two strings s1 and s2
Strcat (s1, s2)
109. Name the function whose definition can be substituted at a place where its function call is made ___________.
Inline function……confirm from net
110. If class A is a friend of class b, and class B is a friend of class C, if class A wants class C to be a friend _________.
It has to declare, class C as a friend….confirm
111. Separate the interface and ________.
Implementation…..confirm
112. Constructor has the same name as of ______.
Class…..confirm
113. Initializing the data members in the definition of the class is a __________.
Syntax error…..confirm
114. The new operator automatically determines the size of memory required to store that object, so it does not need _________.
Sizeof operator…..confirm
115. Object code is machine code but it is not _________ and __________.
Relocateable, executable…….confirm
116. While using ______ operator we do not need to supply number of bytes allocated
New……confirm
117. The operator to free the allocated memory using ______ operator is _________. So whenever we use new to allocate memory.
New, delete…..confirm
118. The _______ operator frees the allocated memory that is returned back to free store for usage ahead.
Delete……confirm
119. The memory allocation functions return a chunk of memory with a pointer of type _________.
Void……confirm
120. The syntax of declaration of a function that returns the reference to an integer is ________.
Int & myfunc();……confirm
121. For console input and output we use _______.
Conia.h header file…..confirm
122. A pointer is _________.
A variable for storing address…….confirm
123. For the joining of two strings in string class, we may use ‘+’ operator, can we use ‘-’ operator the same way for subtracting strings?
No
124. A friend function of a class is a function defined __________.
Outside that class and that has the right access protected members of the class only
125. The reference data types are used as _______ variables without any ______ operator
Ordinary , deference……confirm
126. Operator overloading is to allow the same operator to be ______ to more than one implementation, depending on the types of the operands.
Bound…….confirm
127. The concept of friend function negates the concept of ________.
Encapsulation……confirm
128. Overloaded assignment operator must be
Member function of class
129. Header files provide ______ so the program running on one operating system can run without an error on the other system.
Portability……confirm
130. Once an object is declared as a friend ________.
It has access to all non-public members as if they were public….confirm from net
131. If text is a pointer of type string then what will be the functionality of following statement?
Creates array of 5 objects dynamically
132. A __________ function of a class is defined outside that class scope, but it can access all private and protected members of the class.
Friend
133. For binary member operators operands on the ______ drives (calls) the operation
Left
134. A class is a user defined data type it takes ______________.
No space in memory unless we create an object from it
135. We cannot increment ___________.
Reference…….confirm from net
136. To prevent dangling reference the functions returning reference should be used with _______.
Static and global variables…..confirm from net
137. free function is available in _________ header file.
Stdlib.h
138. Assignment operator is used to initialize a newly declared object from existing object
True……confirm
139. The dynamic memory allocation uses _______ whereas static memory allocation uses ______.
Heap, stack….confirm from net
140. C++ offers _______ levels of data access control inside a class
Three
141. The members of a class declared with the keyboard struct are __________ by default.
Public…..confirm
142. __________ is a special type of pointer we have to cost it before we use it.
Void
143. Encapsulation means __________.
That the data of a class cannot be accessed from outside……confirm
144. The friend keyword provides access ________.
In one direction only …….. confirm
145. Reference variables must __________.
Be initialized after they are declared……confirm
146. Reference is not really an address it is ______.
A synonym……confirm from net
147. C++ was developed by ________
Bjarne Stroustrup……confirm
148. Which of the following syntax is best used to delete an array of 5 objects named ‘string’ allocated using new operator.
Delete []string;
149. if we have a program that writes the output data(numbers) to the disc, and if we collect the output data and write it on the disc in one write operation in the above situation the area where we will gather the number is called.
Buffer…..confirm
150. Consider the following code, the printed value will be converted into
int n = 10;
cout<<oct<<n;
base 8
151. When new operator is overloaded at global level then corresponding built-in new operator will also be visible to whole of the program.
False…..confirm
152. When new operator is overloaded at global level then corresponding built-in new operator will not be visible to whole of the program.
True….confirm
153. To avoid dangling reference, don’t return ___________.
The reference of a local variable from the function…….confirm
154. Reference is a thing by which we can create __________ of any data type
Synonym……confirm from net
155. Reference cannot be uninitialized. Because it is impossible to ________.
Reinitialize a reference……confirm from net
156. _________ must be included to use stream manipulator in your code
Iostream
157. Let suppose int a, b, c, d, e; a=b=c=d=e=42; This can be interpreted by the compiler as
a = (b=(c=(d=(e=42))));
158. What is meant by the following statement? String str[5] = {string(“Programming”), string(“CS201”)};
Parameterized constructor will call for first 2 objects and default constructor for remaining objects…….confirm from net
159. Overloaded member operator function is always called by ______.
Compiler…….confirm from net
160. The default visibility for the data members of the class is
Private……confirm
161. The operator to free the allocated memory using new operator is ________.
delete……confirm
162. Bugs can occur due to ______________.
Uninitialized data…..confirm
163. When the compiler overloads the assignment ( = ) operator by default then
Compiler does member wise assignment……..confirm from net
164. In functions, that returns reference use ___________.
Global or static variables
165. Look at the program code and identify the error. #include<iostream> using namespace std; #define PI 3.1415926; main() { int radius =5; cout<< “Area of circle with radius”<< radius<< ‘ =’ <<PI * radius * radius;}
Error exist in line number 2. Semi colon is not allowed with define directive
166. Destructor ____________.
Cannot be overloaded and have no return type……confirm
167. __________ data isn’t accessible by non-member functions or outside classes
Private…..confirm
168. If the request of new operator is not fulfilled due to insufficient memory in the heap ______.
The operator returns 0…….confirm
169. Symbolic constant PI can be defined as;
#define PI 3.14…….confirm from net
170. Data+=1 is equivalent to ________.
Date+1…….confirm
171. ____________ operators are the ones that require only one operator to work.
Unary……confirm
172. If B is designated as friend of A, B can access A’s non-public members.
A can access non-public members of B……confirm
173. Operator overloading is to allow the same operator to be bound to more than one implementation, depending on the types of the ________.
Operands…..confirm
174. What will be the output of the following c++ code?
#include<iostream.h>
#define max 100
Main()
{
#ifdef max
cout<< “Hellow”;
}
Error……confirm from net
175. While using __________ operator we do not need to supply number of bytes allocated.
New
176. The ________ data type always represents an empty set of values in C++.
Void……confirm
More Important Quiz File
For binary member operators, operands on the ________ drives (calls) the operation.
- Left
- Right
- Both left and right
- None of the given
We cannot increment ________.
- pointers
- arrays
- references
- variables
We can ________ pointer.
- increment
- decrement
- reassign
- all of the given
We can ________ references.
- increment
- decrement
- reassign
- None of the given
What will be the correct syntax for the following function call?
float add (int &);- add(int x);
- add(&x);
- add(x);
- add(*x);
An instance of a class is called ________.
- structure
- data type
- object
- member function
The ________ is called automatically when an object destroys
- destructor
- constructor
- main program
- default constructor
The destructor is used to ________.
- allocate memory
- deallocate memory
- create objects
- allocate static memory
________ data isn't accessible by non-member functions or outside classes.
- Public
- private
- Static
- Globally declared
Member functions of the class ________ main program.
- are not accessible
- are accessible from
- are defined within the
- are private to
Overloading means :
- Using the same name to perform multiple tasks or different tasks depending on the situation.
- Using the different name to perform multiple tasks or different tasks depending on the situation
- Using the same name to perform multiple tasks or same tasks depending on the situation
- Using the same name to perform difficult tasks or complex tasks and it does not depend on the situation
The main advantage of function overloading is ________.
- The program becomes portable
- The program becomes complex
- The function becomes inline
- The program becomes more readable
You cannot overload the ________ operator.
- ? :
- *
- /
- ++
In C++, a variable can be declared anywhere in the program this will increase ________.
- writability
- readability
- portability
- efficiency
Memory allocated from heap or free store ________.
- can be returned back to the system automatically
- can be allocated to classes only
- cannot be returned back unless freed explicitly using malloc and realloc
- cannot be returned back unless freed explicitly using free and delete operators
We cannot use ________ pointer for storing and reading data from it.
- 'NULL
- integer
- double
- zero
The dynamic memory allocation uses ________ whereas static memory allocation uses ________.
- heap , stack
- stack , lists
- array , stack
- classes , array
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';
}- x=23 y=45
- x=24 y=46
- x=24 y=47
- x=22 y=47
NULL has been defined in ________ header file.
- Iostream.h
- Stdlib.h
- Stdio.h
- String.h
Symbolic constant PI can be defined as:
- #define PI 3.14 ;
- #define PI 3.14
- #define PI=3.14
- # include pi= 3.14
The friend function of a class can have access ________.
- to the public data members only
- to the private data members
- to the protected data members
- to the main program
C++ was developed by ________.
- Charles Babbage
- Graham Bell
- Bejarne Stroustrup
- Von Nuemann
Once the ________ are created, they exist for the life time of the program.
- local variables
- non static variables
- static variables
- automatic variables
Encapsulation means ________.
- that the data of a class cannot be accessed from outside
- that the data of a class can be accessed from outside
- the data becomes public
- that the data can be accessible anywhere within a main program
An address is a ________, while a pointer is a ________.
- constant, variable
- variable, constant
- global, variable
- non static variable, constant
The syntax of declaration of a function that returns the reference to an integer is ________.
- int & myfunc();
- int myfunc();
- int myfunc() &;
- integer & myfunc();
Which one of the following is mandatory preprocessor directive for c++?
- #undef
- #include
- #undef
- All of the given
- #undef
The members of a class declared with the keyword struct are ________ by default.
- static
- Private
- protected
- public
With user data type variables (Objects) self assignment can produce
- Link error
- Run time error
- Syntax error
- Logical error
To prevent dangling reference the functions returning reference should be used with ________.
- arrays
- global variables only
- local variables
- static and global variables
When an operator function is defined as member function for a Unary operator then the number of extra arguments it takes is/are,
- Zero
- Two
- One
- N arguments
What is the function of the following statement to delete an array of 5 objects named 'arr' allocated using new operator?
delete arr;- Results into syntax error
- Deletes all the objects of array
- Do not delete any object
- Deletes only one object of array
getche() is a ________ function and defined in ________ header file.
- user-define function , conio.h
- built-in function , conio.h
- built-in function, stlib.h
- built -in function, iostream.h
________ operators are the ones that require two operands on both sides of the operator.
- Double
- Tow sided
- Binary
- None of the given
________ will return the number of bytes reserved for a variable or data type.
- sizeof operator
- free operator
- void pointer
- new operator
________ are not available in C language.
- User defned functions
- Built in functions
- Library functions
- Inline functions
The members of a class declared without any keyword are ________ by default.
- protected
- private
- public
- constant
For console input and output we use ________.
- conio.h header file
- stdlib.h header file
- process.h header file
- getch.h header file
The name of the destructor is the same as that of a class proceeding with a ________.
- & sign
- # sign
- @ sign
- ~ sign
A reference cannot be NULL it has to point a data type.
- True
- False
A pointer is ________.
- the address of a variable
- an indication of the variable to be accessed next
- a variable for storing address
- the data type of an address variable
Constructor is a special function, called whenever we ________.
- create a function
- instantiate an object of a class
- destroy an object
- create a class
Symbolic constant PI can be defined as:
- #define PI 3.14;
- #define PI 3.14
- #define PI=3.14
- # include pi=3.14
Object code is machine code but it is not ________ and ________.
- relocatable, executable
- faster, efficient
- compiled, debugged
- tested, compiled
The default visibility for the data members of the class is
- private
- protected
- public
- accessible outside the class
The ________ is called automatically when an object destroys.
- destructor
- constructor
- main program
- default constructor
Constructor is special type of function :
- which has no return type
- which returns NULL pointer
- which returns zero
- which returns integer type data
________ variables are those that are defined outside of main.
- Local
- Dynamic
- Global
- Static
Within the statement obj1=obj2; obj1 will call the assignment operator function and obj2 will be passed as an argument to function.
- True
- False
When the compiler overload the assignment (=) operator by default then
- Class members are not assigned properly
- Compiler does not allow default assignment operator
- Compiler does member wise assignment.
- None of the given
It is possible to return an object from function using this pointer.
- True
- False
Overloaded assignment operator must be
- Member function of class
- Non-member function of class
- Friend function of class
- Global function
Let suppose
int a, b, c, d, e;
a = b = c = d = e = 42;
This can be interpreted by the compiler as- (a = b = (c = (d = (e = 42))));
- a = (b = (c = (d = (e = 42))));
- a = b = (c = (d = (e = 42)));
- (a = b) = (c = d) = (e = 42);
In statement a+b+c, at first
- a+b is executed first
- b+c is executed first
- All executed at the same time
- None of the given
Suppose int i = 10; then what is the output of cout<<oct<<i;
- 10
- 11
- 12
- 13
ostream is a ________ operator.
- dependent
- member
- standalone
- None of the given
________ must be included to use stream manipulation in your code.
- conio.h
- iostream
- stdlib.h
- iomanip
________ operators are the ones that require only one operator to work.
- Unit
- Unary
- Single
- None of the given
The endl and flush are ________.
- Functions
- Operators
- Manipulators
- Objects
When operator function is implemented as member function then return type of function ________.
- Must be an object of same class
- Must be user-defined data type
- Must be built-in data type
- Can be any data type
When a variable is defined as static in a class then ________.
- Separate copy of this variable is created for each object
- Only one copy is created for all objects of this class
- A copy of this variable is created for only static objects
- None of the given
Automatic variables are created on ________.
- Heap
- Free store
- Static storage
- stack
cout << i << " ";
cout << d <<" ";
cout << f;
Above statements can be written within statement of one line as:- cout << i <<" "<< d " "<< f << ;
- cout << i << << d << << f <<;
- cout << i <<" "<< d <<" "<< f;
- cout << i << " "<< d <<" " f<<;
dec, hex, oct are all ________.
- Member functions
- Objects of input/output streams
- Parameterized manipulators
- Non-parameterized manipulators
What will be the output of following statement?
cout<<setfill('0')<<setw(7)<< 128;- 0128128
- 0000128
- 1280000
- 0012800
Which of the following syntax is best used to delete an array of 5 objects named 'string' allocated using new operator.
- delete string;
- delete []string;
- delete string[];
- delete string[5];
If we have a program that writes the output data(numbers) to the disc, and if we collect the output data and write it on the disc in one write operation instead of writing the numbers one by one.
In the above situation the area where we will gather the number is called- Heap
- Stack
- Buffer
- Cache
The first parameter of operator function for << operator ________.
- Must be passed by value
- Must be passed by reference
- Can be passed by value or reference
- Must be object of class
The second parameter of operator function for >> operator must always be passed
- By reference
- Function takes no argument
- By value
- None of the given
The only operator that the compiler overloads for user define data type by default is
- Plus (+) operator
- MInus (-) operator
- Assignment (=) operator
- Equal (==) operator
Consider the following code, the printed value will be converted into:
int n=10;
cout <<oct<<n;- Base 8
- Base 2
- Base 10
- Decimal number system
________ variables are defined in the main.
- Global
- Dynamic
- Local
- All
ostream class is ________ and not under our control.
- user-defined
- built-in
- both user-defined and built-in
- None of the given
The memory allocation in C++ is carried out with the help of ________.
- NULL pointer
- new operator
- dot operator
- + operator
If B is designated as friend of A, B can access A's non-public members.
- B cannot access private member of A
- B cannot access protected member of A
- A can access non-public members of B
- A cannot access B
If the request of new operator is not fulfilled due to insufficient memory in the heap ________.
- the new operator returns 2
- the new operator returns 1
- the operator returns 0
- free operator returns nothing
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.
- upper case alphabets
- lower case alphabets
- double underscore
- None of the given
The friend keyword provides access ________.
- in one direction only
- in two directions
- to all classes
- to the data members of the friend class only
The malloc function takes ________ argument(s).
- two
- three
- four
- one
The constructor contains ________.
- return type
- no return type
- objects
- classes
What will be the output of the following c++ code?
#include<iostream.h>
#define max 100
main()
{
#ifdef max
Cout<<"Hellow;
}- Hello
- "Hellow"
- Max is 100
- Error
Once we have defined a symbolic constant value using #define, that value ________ during program execution
- can be changed
- cannot be changed
- varies
- becomes zero
The memory allocation functions return a chunk of memory with a pointer of type ________.
- integer
- float
- ptr
- void
A class can be declared as a ________ of other class.
- member
- member function
- friend
- part
To avoid dangling reference, don't return ________.
- the reference of a local variable from the function
- the reference of a global variable from the function
- the reference of a static variable from the function
- the reference of a private data member from the function
Constructor is itself a ________ of C++ and ________.
- class, can be overloaded
- function, cannot be overloaded
- function, can be overloaded
- object, can not be initialized
The parameter passed to isdigit() function is ________ variable.
- Character
- Boolean
- Integer
- Float
char **argv can be read as ________.
- pointer to pointer
- pointer to char
- pointer to pointer to char
- None of the given
To read command-line arguments, the main() function itself must be given ________ arguments.
- 1
- 2
- 3
- 4
How many bytes an integer type pointer intPtr will jump in memory if the statement below is executed?
intPtr += 2 ;- 2
- 4
- 8
- 12
The increment of a pointer depends on its ________.
- variable
- value
- data type
- None of the given
The statement cout << yptr will show the ________ the yptr points to.
- Value
- memory address
- variable
- None of the given
________ is used as a dereferencing operator.
- *
- +
- -
- None of the above
Transpose of a matrix means that when we interchange rows and columns ________.
- the first row becomes the Last column
- the first row becomes the first column
- the Last row becomes the first column
- the first column becomes the first row
Individual characters in a string stored in an array can be accessed directly using array ________.
- superscript
- script
- subscript
- value
We can define a matrix as ________ array.
- Sorted
- Unsorted
- Single dimensional
- Multi dimensional
A ________ is an array of characters that can store number of character specified.
- Char
- String
- Multidimensional array
- Data type
Given a two dimensional array of integers, what would be the correct way of assigning the value 6 to the element at third row and fourth column?
- array[3][4] = 6 ;
- array[2][4] = 6 ;
- array[4][3] = 6 ;
- array[2][3] = 6 ;
________ of a variable means the locations within a program from where it can be accessed.
- Data type
- Visibility
- Value
- Reference
Which of the following function call is "call by reference" for the following function prototype?
int add (int *);- add(&x);
- add(int x);
- add(x);
- add(*x);
Which of the following function call is "call by reference" for the following function prototype?
float add (float *);- add(&x);
- add(float x);
- add(x);
- add(*x);
Which of the function call is call by value for the following function prototype?
float add(float);- add(&x);
- add(x);
- add(float x);
- add(*x);
Which of the function call is "call by value" for the following function prototype?
float add(int);- add(&x);
- add(x);
- add(int x);
- add(*x);
Return type of a function that does not return any value must be ________.
- char
- int
- void
- double
________ will be used for enclosing function statements into a block.
- " "
- ()
- []
- {}
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;
}- banana
- banana
any fruit - banana
mango
any fruit - None of the given
When the break statement is encountered in a loop's body, it transfers the control ________ from the current loop.
- Inside
- Outside
- To break statement
- To continue statement
What is the output of the following code if the 3rd 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;
}- mango
- mango
any fruit - apple
- None of the given
What is the output of the following code, if the first 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;
}- apple
- apple
any fruit - apple
banana
mango
any fruit - none of above
What will be the output of following code segment?
for (int i = 2; i<10; i++) {
if ( i == 5) continue;
cout << i << "," ;
}- 2,3,7,8,9
- 2,3,4,6,7,8,9
- 2,3,4
- 4,6,7,8,9
________ statement is used to terminate the processing of a particular case and exit from switch structure.
- if
- goto
- break
- continue
What will be the result of the expression j = i++; if initially j = 0 and i = 5?
- 0
- 5
- 6
- 4
What will be the result of the expression k = ++m; if initially k = 0 and m = 4?
- 0
- 5
- 6
- 4
What will be the result of the expression k = ++m; if initially k = 0 and m = 5?
- 0
- 5
- 6
- 4
How many times the following do-while loop will execute?
int k = 10; do { cout << "Statements" << endl; k -= 2; } while(k>0);- 4
- 5
- 6
- 7
Which of the following loops checks the test condition at the end of the loop?
- While
- Do-While
- For
- Nested Loop
The operators ++ and -- are used to increment or decrement the value of a variable by ________.
- 3
- 2
- 1
- 4
How many times the following loop will execute?
int j = 3; while(j > 0) { cout << "Statements" << endl; j -= 2; }- 0
- 1
- 2
- 3
A ________ structure specifies that an action is to be repeated while some condition remains true.
- Control
- Logical
- Repetition
- Relational
!( x > 3) means in C++ that
- x is greater than 3
- x is less than or equal to 3
- x is less than 3
- x is equal to 3
When the logical operator && combines two expressions then the result will be true only when the both expressions are ________.
- Logical
- Arithmetic
- true
- false
< and > both are ________ operators.
- Arithmetic
- Relational
- Logical
- Mathematical
What will be the value of variable “input” if the initial value of input is 67?
if(input >= 50)
input = input + 1;
if(input <= 75)
input = input + 2;
else
input = input - 1;- 68
- 69
- 70
- 66
!( x < 3) means in C++ that
- x is less than 3
- x is greater than or equal to 3
- x is greater than 3
- x is equal to 3
!= operator is used to check whether the operand on the left-hand-side is __________ to the operand on the right-hand-side.
- Less than or equal
- Greater than or equal
- Not equal
- Approximately equal to
When the if statement consists more than one statement then enclosing these statement in curly braces is,
- Not required
- Good programming
- Relevant
- Must
The most suitable data type for number 325.25 is ________.
- char
- int
- short
- float
What will be the result of arithmetic expression 6+48/4*3?
- 10
- 40.5
- 42
- 41
Which of the following will be the most appropriate data type to store the value 63.547?
- Integer
- Character
- Short
- Float
In the given expression which operator will be evaluated first? 10 + (6 / 2) - 2 * 3?
- +
- -
- /
- *
What will be the value of the variable output in the given piece of code?
double output = 0;
output = (2 + 2) * 4 + 2 / (4 - 2);- 15
- 17
- 12
- 11
It is the job of ________ to transfer the executable code from hard disk to main memory.
- interpreter
- Debugger
- Linker
- Loader
In computer systems there are mainly ________ type of softwares.
- 1
- 2
- 3
- 4
________ will explain the function of a program.
- Comments
- Debugger
- Compiler
- Linker
if (a>b && a>c) then the condition will be true only if
- Both a>b and a>c are true
- a>b is false and a>c is true
- a>b is true and a>c is false
- Both a>b and a>c are false
A variable of character data type occupies ________ byte(s) in memory.
- 1
- 2
- 4
- 8
We must include the header file ________ to convert the value of one type into another type using built-in functions.
- conio.h
- stdlib.h
- string.h
- iostream.h
A function is a block of statements that can be defined once and used ________ in the program.
- One time
- Two times
- Three times
- As many times as user wants
Select the correct way to assign the address of first element of array to pointer?
- int *ptr = &data[1];
- int *ptr = &data;
- int *ptr = data;
- int *ptr = data[0];
Consider the following code segment. What will be the output of following code?
int addValue (int *a){
int b = (*a) + 2;
return b;
}
main() {
int x = 6;
cout<<addValue(&x)<<",";
cout<<x;
}- 6,8,6
- 6,6,8
- 6,8,8
- 6,6,6
Here the code is given below. You have to identify the problem in the code.
while(i < 10) && (i > 24))- the logical operator && cannot be used in test condition
- the while loop is an exit-condition loop
- the test condition is always true
- the test condition is always false
The correct syntax of do-while loop is ________.
- (condition) while; do {statements;};
- {statements;} do-while();
- while(condition); do {statements;};
- do {statements;} while (condition);
Matrix is defined as ________.
- Single dimensional array
- Multi-dimensional array
- Vector product
- Scalar product
In programming, comments are used to explain the functioning of the ________.
- Debugger
- Editor
- Program
- Linker
Operating System is a type of a/an ________.
- application software
- system software
- computer language
- interpreter
From the options given, you need to choose the option which is true for the given code.
for (int i = 1; i>0; i++) {
/*loop code*/
}- the logical operator && cannot be used in a test condition
- the while loop is an exit-condition loop
- the test condition is always false
- the test condition is always true
Which of the following values are used in C/C++ to represent true and false?
- 1 and 0
- 1 and -1
- 11 and 00
- any numerical value
'While' loop may execute ________ or more times.
- three
- zero
- two
- one
Body of any function is enclosed within ________.
- { }
- ( )
- [ ]
- " "
What will be the correct syntax for initialization of a pointer ptr with string "programming"?
- char ptr = 'programming';
- char *ptr = "programming";
- char *ptr = 'programming';
- *ptr = "programming";
Which one of the given option is not a mode for reading/writing the data from a file?
- in
- out
- trunc
- get
Which of the following operators is used to access the value of variable pointed by a pointer?
- * operator
- -> operator
- && operator
- & operator
In case of single dereferencing, the value of the ________ is the address of the ________.
- pointer, variable
- pointer, constant
- variable, pointer
- constant, pointer
The remainder (%) operator is a ________ operator.
- Logical
- Arithmetic
- Relational
- Conditional
What will be the output of following code?
int x = 10;
cout<<"x="<<x;- 10
- "x=10"
- x=10
- 10=x
The purpose of using cout<< is to ________.
- Display information on the screen
- Read the data from keyboard
- Read the data from a file
- Write into a file
Which of the following data types will be assumed if no data type is specified with constant?
- short
- float
- int
- double
When an array element is passed to a function, it is passed by ________.
- reference
- data type
- value
- data
While programming, it is good to provide an easy to understand and easy to use interface; this programming skill is called ________.
- scalability
- usability
- reliability
- sustainability
________ executes all the lines before error and stops at the line which contains the error.
- Intrepreter
- Compiler
- Linker
- Debugger
Which of the following is the correct syntax to access the value of first element of an array using pointer ptr?
- ptr[0]
- *(ptr+1)
- ptr[1]
- *ptr[0]
C is a/an ________ language.
- low level
- object based
- object oriented
- function oriented
________ of a function is also known as signature of a function.
- Definition
- Declaration
- Calling
- Invoking
________ are very good tools for code reuse.
- operators
- loops
- functions
- variables
If any break statement is missed in switch statement then ________.
- compiler will give error
- this may cause a logical error
- no effect on program
- program stops its execution
A 2D array multi[5][10] can be accessed using the array name as **multi, this technique is called ________.
- Single referencing
- Single dereferencing
- Double referencing
- Double dereferencing
In C/C++, the default command line arguments passed to the main function are ________.
- float argc, char **argv
- int argc, char **argv
- int *argc, char *argv
- int argc, float **argv
A record is a group of related ________.
- Data
- Fields
- Bytes
- Files
The microsoft word document (.doc) is a kind of ________.
- Sequential File
- Random Access File
- Binary Access File
- Executable File
NULL character is used to indicate the ________ of string.
- Start
- End
- Begin
- Middle
How many dimensions does n-dimensional array has?
- n dimensions
- 2n dimensions
- (n+1) dimensions
- (n-1) dimensions
Which of the following function call is "call by reference" for the following function prototype?
- func(int &num);
- func(&num);
- func(*num);
- func(num);
The loop which is most suitable to be used when the number of iterations is known is called ________.
- for
- while
- do-while
- all looping processes require that the iterations be known.
In C/C++, the string constant is enclosed in ________.
- curly braces { }
- parentheses( )
- single quotes ' '
- double quotes " "
In order to get the right most digit of a number, we divide this number by 10 and take ________.
- Its remainder
- Its quotient
- Its divisor
- The number
What is the correct syntax to declare an array of size 10 of int data type?
- int [10] name;
- name[10] int;
- int name[10];
- int name[];
How many bytes of memory are occupied by array 'str'?
char str[] = "programming";- 10
- 11
- 12
- 13
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?
- 0x22f231
- 0x22f234
- 0x22f226
- 0x22f238
Which of the following if missing would result in infinite recursion in case of recursive function?
- Recursive call
- Base case
- Function parameters
- Local variables
Whenever we use a library function or a predefined object or macro, we need to use a ________.
- source file
- object file
- header file
- exe file
Switch statement deals with ________ type of data.
- Integer
- Float
- Character
- Both Integer and Character
Both compiler and ________ are used to translate program into machine language code.
- debugger
- linker
- loader
- interpreter
TWAIN stands for ________.
- Technology With An Interesting Name
- Technology Without An Informative Name
- Technology Without An Interesting Name
- Technology With An Informative Name
The parameter passed to isdigit() function is ________.
- a character variable
- a boolean variable
- an integer variable
- a character string
C++ views each file as a sequential stream of ________.
- Bits
- Bytes
- Numbers
- Words
Structure is a collection of ________ under a single name.
- only functions
- only variables
- both functions and variables
- only data types
The default mode for writing into a file using ofstream object is ________.
- out
- bin
- app
- ate
The memory address of the first element of an array is called ________.
- floor address
- foundation address
- first address
- base address
We want to access array in random order which of the following approach is better?
- Pointer
- Array index
- Both pointers and array index are better
- Matrix
The ________ structure is a multiple-selection construct which makes the code more efficient and easy to read and understand.
- multiple-if
- switch
- if-else
- else-if
Which of the following is not a reserved word in C/C++?
- int
- float
- double
- sum
To access rand(), which library is required to be included in program?
- conio.h
- stdio.h
- stdlib.h
- iostream.h
What is the highest legal index for the following array?
int arr[4]- 4
- 3
- 2
- 1
Word processor is a type of a/an ________.
- operating system
- application software
- device driver
- utility software
Identify the correct option which is used for calling the function float area (int).
- area(&num);
- area(num);
- area(int num);
- area(*num);
The ________ statement allows us to select from multiple choices based on a set of fixed values for a given expression.
- switch
- break
- continue
- goto
C is widely known as development language of ________ operating system.
- Windows
- Unix
- Mac OS
- Linux
To convert the value of one type into another type using built-in functions, we include ________ header file.
- conio.h
- stdlib.h
- iostream.h
- string.h
The keyword ________ is used to get some value back from a function.
- return
- break
- continue
- goto
The function seekg() takes ________ parameter(s).
- 0
- 1
- 2
- 3
The function write() takes ________ as parameter(s).
- String of pointer type
- String of variable lengths, no. of bytes to be read and flags
- Poimter array of characters and a delimiter
- String and no. of bytes to be written
When the logical operator AND (&&) combines two expressions exp1 and exp2 then the result will be true only ________.
- When both exp1 and exp2 are true
- When both exp1 and exp2 are false
- When exp1 is true and exp2 is false
- When exp1 is false and exp2 is true
Syntax of a union is identical to ________.
- structure
- class
- function
- loop
Which one of the symbol is used to represent a decision in a flow chart?
In Flow Chart, flow of control is represented by ________.
- Rectangle
- Circle
- Diamomd
- Arrow
There can be ________ 'default' statement(s) in any switch structure.
- 1
- 2
- 3
- n
The condition in loop should be a(n) ________.
- Constant Expression
- Boolean Expression
- Primary Expression
- Arithmetic Expression
How many nested loops would be required to manipulate n-dimensional array?
- n
- n + 1
- n - 1
- 2n
Which of the following is not an example of int data type?
- 0
- -32
- 65531
- -4
We should use ________ for clarity and to force the order of evaluation in an expression.
- brackets []
- parenthesis ()
- curly braces {}
- quotation marks " "
Which of the following is the starting index of an array in C++?
- 0
- 1
- -1
- 2
The statement x += y can be interpreted as ________.
- Adding the value of the x to the value of the y and storing the result in x
- Adding the value of the y to the value of x, store the result in y
- Adding the value of the x to the value of x, store the result in x
- Adding the value of the y to the value of y, store the result in x
Given a 2D array of integers, what would be the correct way of assigning the value 5 to the element at second row and third column?
- m[2][3] = 5;
- m[3][2] = 5;
- m[1][2] = 5;
- m[2][3] = '5';
Array is a data structure that stores ________.
- Memory addresses
- Variables
- Data type
- Data
A program statement that invokes a function is called ________.
- function declaration
- function call
- function definition
- function prototype
If a function has been declared but not defined before its function call then it is termed as ________.
- logical error
- syntax error
- run time error
- program time error
The compiler of C language is written in ________ language.
- JAVA
- BASIC
- FORTRAN
- C
Which one of the below functions is not included in ctype.h header file?
- isdigit(int c)
- isxdigit(int c)
- tolower(int c)
- getdigit(int c)
Which function is used to locate the first occurance of a character in any string?
- strchr()
- strstr()
- strtok()
- strlen()
To access the data members of structure, ________ is used.
- Logical operator
- Dereference operator
- Dot operator
- Address operator
In the following nested For Loop, which loop will run most number of times?
for( int i = 0; i < 5; i++)
{
for(int k = 0; k < 5; k++)
{
. . . . .
}
}- Outer loop
- Inner loop
- Both loops run equal number of times
- Depends upon the statements in the inner loop's body
Structure use ________ allocation.
- Queue
- Heap
- Cache
- Stack
________ function give the position of the next character to be read from that file.
- tellp()
- tellg()
- seekg()
- seekp()
What will be the size of the following character array?
char name[] = "Adeel";- 5
- 6
- 4
- 7
Function prototype is written,
- Within main function
- After the return statement in main
- Before the return statement in main
- Before call of that function
Which one of the following languages has been used to write the compiler of "C" language?
- Java
- Fortran
- Basic
- C
A hierarchy of classes which are used to deal with console and disk files are called ________.
- Stream classes
- Simple classes
- Binary classes
- IO classes
________ stops execution at the line that contains error(s) in the code.
- Compiler
- Debugger
- Interpreter
- Linker
C++ is a ________ language.
- High level
- Low level
- Machine
- Assembly language
How many elements are stored in the following?
int matrix [4][5];- 9
- 20
- 25
- 10
________ is a substitute of multiple if statement.
- if. . .elseif statement
- Continue statement
- Break statement
- Default statement
if
int sum = 54;
Then the value of the following statement is
sum = sum - 3;- 52
- 50
- 51
- 57
What will be the correct syntax for declaration of the following statement?
"ptr is a constant pointer to an integer"- const * int myptr;
- const int *myptr;
- int const *ptr;
- int *const ptr;
________ operator is used to pass the address of a variable in call by reference method.
- %
- +
- @
- &
________ data type can operate on modulus operator.
- int
- float
- char
- double
Whenever some number is added in an array name, it will jump as many ________ as the added number.
- rows
- value
- column
- bytes
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?
- 0x22f221
- 0x22f222
- 0x22f223
- 0x22f224
Which of the following structure is correct for WHILE loop?
- While (start; condition; end)
- While (start; condition)
- While (condition; end)
- While (condition)
Which of the following is true about the switch statement?
- It is valid for the large programs only.
- It is valid for the small programs only.
- It works efficiently on compound conditions which use logical operators.
- It cannot handle the compound conditions which use logical operators.
If the condition is not made false in while loop, what will happen?
- Loop will become infinite.
- Program will not run at all.
- Program will terminate early.
- Syntax errors occur.
If a function does not return anything, its return type will be ________.
- Return 0
- Null
- Zero
- Void
What will be the output of the following piece of code?
int square(int number)
{
int result 0;
result = number * number;
return result;
}
int main()
{
cout<<square(9);
}- 49
- 99
- 89
- 81
Which of the following is the first step in FOR loop?
- Incrementing condition
- Termination condition
- Continuation condition
- Initialization condition
Learning "how to program" is important, because it develops ________ and problem-solving abilities.
- Analytical
- Writing
- Listening
- Reading
In C++, which of the following option has the cottect meaning of the expression a <= b"?
- a is greater than or equal to b
- a is less than b
- a is greater than b
- a is less than or equal to b
What will be the output of following code?
int i = 1;
while(i<10){
if(i%2 == 0)
cout<<i<<" ";
i++;
}- 2 4 6 10
- 1 3 5 7
- 2 4 6 8
- 2 4 8 10
What will be the output of following code?
int x = 15;
int y = 10;
int z = 5;
cout<< x * x - 4 * y * z;- 25
- -25
- -5
- 5
Which of the following expression is correct in C/C++ language?
- X = X + 3
- 3 = X + 3
- Y + X = 7
- X + 5 = Y + 7
Which of the following C++ statements is used take input from the user?
- cin
- cerr
- cout
- cget
Which of the following is an example of logical operator?
- &&,||
- <,>
- +,*
- /,%
In C/C++, which of the following data type is used to store real numbers?
- float
- char
- boolean
- int
C/C++ has many libraries which contain variables and function names normally starting with ________.
- Hyphen
- Hash
- Underscore
- emi-Colon
The coding of a program is translated into machine language by ________.
- Debugger
- Compiler
- Loader
- Linker
What will be the output of the following code?
int i = 0;
while(i!=15){
cout<<i<<" ";
i = i + 5;
}- 1 5 10
- 5 10
- 0 5
- 0 5 10
In C/C++, the algebraic expression (b2-4ac) / 2a can be written as:
- (b*b - 4*a*c) / (2*a)
- b*b - 4*a*c / (2*a)
- b*b - 4*a*c / 2*a
- b*b - (4*a*c) / 2*a
________ is the pointer which determines the position in a file from where the next read operation occurs.
- put
- seek
- get
- tell
We are here to provide Latest Virtual University Assignment Solutions, GDB Solutions, Quiz Solution, Midterm Past Papers, and Final term Past Papers in this website.
Thanks everone