CS201 Grand Quiz File (New) by Nimra Khan
CS201 Grand Quiz File (New) by Nimra Khan
1. ------ is used for input file or for reading from the file.
Tellg()
13. What is the output of thw following code if the 3rd case is
true
Switch (var)
{Case ‘a’;
Cout<<”apple”<<endl;
Mango
33. Mr. ahmad sleeps thirty hours every day. This sentence
is ----
Grammatically correct but illogical
37. The expression ((a+b) = = 10) || ((x+y) = = 20) is true only if?
Either ((a+b) = =) OR ((x + y) = =20) is true
58. which of the following is the default mode of the opening using of
ofstream class?
Ios::trunc
62. Which of the following is the correct operator to compare the values of
two variables?
==
67. ! = operator is used to check whether the operand on the left-hand side
is------to the operand on the right-hand-side.
Not equal
69. How we declare an array of integer data whose size is 20 with array
name “count”.
Int count[20];
70. A variable declared within a code block becomes ---- variable for that
block.
Local
73. ---- Loop is mostly used to perform repetition of a tasks for a known
number of times.
For
74. In shifting operations if zero is inserted at the lest most bit, the
negative number will become a ---- number.
Positive
75. It is the job of ---- to transfer the executable code from hard disk to
main memory.
Loader
79. How many times the following do-while loop will execute?
Int k = 10;
Do
{
Cout << “statements” << endle; ?
6
83. ------- allow us to have a memory location and use it as int or char
interchangeably.
None of the given
//varaibles
};
90. The use of *sign in first and second statements is called --- and ----
of pointer.
Int *ptr = &x;
Cout<<*ptr; ?
Referencing, dereferencing
96. We can read, write and manipulate the same file using ----
Fstream.h
97. Return type of a function that does not return any value must be ----
Void
102. Compiler translates high level language program into ---- language
code.
Machine
103. Each array declaration must provide the information about all these
things except----
The location of the first element to be stored
104. Eof is used to check for the --- of file when a file is being resd.
End
106. When the logical operator AND (&&) combine two expression exp1 and
exp2 then the result will be true only?
When both exp1 and exp2 are true
107. ‘multi[3][3]’ element can also be accessed by ------
*(*(multi + 3) + 3)
109. Which of the following is not the subcategory of the system software?
None of the above
120. -------- is used for output during the process of writing to the file.
Seekp()
121. In while loop the condition is checked ---- the execution of loop.
Before
124. Which step is not not performed during a proper program design?
Write details about the performance of program
125, We can say that a pointer is a variable that holds the --- address.
Memory
126. When accessing a structure memory, the identifier to the left of the
dot operator is the name of ----
Structure variable
127. From the following; which one is the range of random number
generator rand() ?
O – 32767
131. What will be the value of the variable output in the given piece of code?
Double output = 0;
Output = (2 +2) * 4 + / (4 – 2);
17
132. What is the output of the following statement?
int i = 2.5; do { cout i * 2; } while (i > 3 && i < 10);
error
When the logical operator OR (||) combine two expressions exp1 and exp2
then the result will be false only, //bitwise “or” applies here….
When both exp1 and exp2 are false
suppose we have int y[10]; To access the 4th element of the array we
write_________
none of given
The variables having a name, type and size are just like empty boxes.
True
Which of the following loops checks the test condition at the end of the
loop?
Do-While
From the following; which one is the range of Random number generator
function rand()?
0 – 32767
Which of the function call is call by value for the following function
prototype? float add(int);
add(x);
The name of the array is a constant pointer which contains the memory
address of the ____________of the array.
first element
array name always contains the memory address of the ___________of the
array
first element
A union is a user-defined data type that contains only _______from its list
of members at a
time.
one object
Which of the given file handling modes are similar in their functionality ?
ios::trunc, ios::ate
Which one of the given option is not a mode for reading/writing the data
from a file?
Trunk
The __________ statement forces the immediate next iteration of the loop.
Continue
___________ executes all the lines before error and stops at the line which
contains the error.
Intrepreter
Which of the following is the correct function call, having array named
student of 10
elements as a parameter?
addRecord(student);
What is the correct syntax to declare an array of size 10 of int data type?
int name[10] ;
When accessing a structure member, the identifier to the left of the dot
operator is the
name of ______________.
a structure variable
The parameter passed to isdigit() function is ____________.
a character variable
From the option given below, what will be the correct output of the code?
for (int a = 1; a <= 3; a++)
cout<<a*3-1<<" ";
258
If the return type of a function is void then it means that it will _________.
return any type of data
return no data
The functions that have already been defined as a part of the language are
called
___________.
built-in functions
Given that doubleArray is an array of 7 integers. Which of the below is the
correct statement to access the 5th element of the array?
doubleArray[4]
In ________, the first pointer stores the address of the some other pointer,
which contains the address of any variable.
single dereference
Initialization of variable at the time of definition is --------------practice.
Good Programming
Which looping process checks the test condition at the end of the loop?
do-while
You can use a _________ statement to transfer control elsewhere out of the
nested structure.
Goto
Which of the following array is the most suitable for storing a matrix
structure?
Single-dimensional array
A union is a user-defined data type that contains only _______from its list
of members at a time.
one object
In C/C++, ___________ are the doors through which data can enter and come
out of a program.
Streams
Which one of the given option is not a mode for reading/writing the data
from a file?
Trunk
From the options given below, identify the correct option which is used for
calling the function float square (int &);
square (num);
Identify the correct option which is used for calling the function float area
(int).
area(num) ;
Which kind of error occurs in the code below to access the variable num
in the main
function?
int num =10;
int main(){
int x ;
x = num ;
}
No error
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
For which array, the size of the array should be one more than the number
of elements in an array?
char
What is the range of Random number generator function rand()?
0 – 32767
What will be the correct syntax for initialization of pointer ptr of type int
with variable x?
int *ptr = &x ;
Syntax of a union is identical to __________ .
structure
A union is a user-defined data type that contains only _______from its list
of members at a time.
one object
Which of the given file handling modes are similar in their functionality ?
ios::trunc, ios::ate
Which one of the given option is not a mode for reading/writing the data
from a file?
Trunk
When accessing a structure member, the identifier to the left of the dot
operator is the name of ______________.
a structure variable
The parameter passed to isdigit() function is ____________.
a character variable
From the option given below, what will be the correct output of the code?
for (int a = 1; a <= 3; a++)
cout<<a*3-1<<" ";
258
If the return type of a function is void then it means that it will _________.
return no data
The functions that have already been defined as a part of the language are
called
___________.
built-in functions
Given that doubleArray is an array of 7 integers. Which of the below is the
correct
statement to access the 5th element of the array?
doubleArray[4]
In ________, the first pointer stores the address of the some other pointer,
which contains the address of any variable.
single dereference
You can use a _________ statement to transfer control elsewhere out of the
nested structure.
Goto
An object of _________ class can be created for saving the current position
of any opened file
before reading from the file
Stream
If a file is not properly closed in a program then what is the status of the
program ?
The program will terminate normally
Each array declaration must provide the information about all these things
except
__________.
Number of elements of the array
___________ transfers the executable code from hard disk to main memory.
Loader
Which of the following is the correct function call, having array named
student of 10 elements as a parameter?
addRecord(student[10]);
Which of the following array is the most suitable for storing a matrix
structure?
Two-dimensional array
The second parameter of operator functions for << and >> are objects of
the class for which we are overloading these operators.
► True
What will be the correct syntax to access the value of fourth element of an
array using pointer ptr?
► Both 1and 3
new operator is used to allocate memory from the free store during
► None of the given options
When an object of a class is defined inside another class then,
► Destructor of inner object will be called first
New and Delete are also used with ___________ and data types as well.
► Class, Objects
With New keyword, data types and class members are initialized with
meaningful values instead of garbage.
► True
C language is developed by
► Dennis Ritchie
Compiler is a
► Application Software
In C/C++ language the header file which is used to perform useful task and
manipulation of character data is
► ctype.h
What is the correct syntax to declare an array of size 10 of int data type?
► int name[10] ;
Which of the following values C++ use to represent true and false?
► 1 and 0
For which array, the size of the array should be one more than the number
of elements in an array?
► char
Which header file must be included to use the functions tolower() and
toupper()?
ctype.h
eof is used to check for the _________ of file when a file is being read.
End
The statement cout << yptr will show the __________the yptr points to.
memory address
An object of _________ class can be created for saving the current position
of any opened file before reading from the file.
Stream
IO classes
For binary member operators, operands on the ________ drives (calls) the
operation.
Left
What will be the correct syntax for the following function call?
add(x);
An instance of a class is called ________.
object
Overloading means :
Using the same name to perform multiple tasks or different tasks
depending on the situation.
We cannot use ________ pointer for storing and reading data from it.
'NULL
Once the ________ are created, they exist for the life time of the program.
static variables
The members of a class declared with the keyword struct are ________ by
default.
Public
________ operators are the ones that require two operands on both sides of
the operator.
Binary
________ will return the number of bytes reserved for a variable or data
type.
sizeof operator
The name of the destructor is the same as that of a class proceeding with
a ________.
~ sign
A pointer is ________.
a variable for storing address
Within the statement obj1=obj2; obj1 will call the assignment operator
function and obj2 will be passed as an argument to function.
True
When the compiler overload the assignment (=) operator by default then
Compiler does member wise assignment.
It is possible to return an object from function using this pointer.
True
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))));
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
Buffer
The second parameter of operator function for >> operator must always be
passed
By reference
The only operator that the compiler overloads for user define data type by
default is------
Assignment (=) operator
Consider the following code, the printed value will be converted into:
int n=10;
cout <<oct<<n;
Base 8
The memory allocation in C++ is carried out with the help of ________.
new operator
The statement cout << yptr will show the ________ the yptr points to.
memory address
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[2][3] = 6;
Which of the following function call is "call by reference" for the following
function prototype? int add (int *);
add(&x);
Which of the following function call is "call by reference" for the following
function prototype? float add (float *);
add(&x);
Which of the function call is call by value for the following function
prototype? float add(float);
add(x);
Which of the function call is "call by value" for the following function
prototype? float add(int);
add(x);
Return type of a function that does not return any value must be ________.
void
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 any fruit
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 banana mango any fruit
Which of the following loops checks the test condition at the end of the
loop?
Do-While
When the logical operator && combines two expressions then the result
will be true only when the both expressions are ________.
true
What will be the value of variable “input” if the initial value of input is 67?
70
When the if statement consists more than one statement then enclosing
these statement in curly braces is,
Must
Which of the following will be the most appropriate data type to store the
value 63.547?
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);
17
It is the job of ________ to transfer the executable code from hard disk to
main memory.
Loader
Select the correct way to assign the address of first element of array to
pointer?
int *ptr = &data;
Consider the following code segment. What will be the output of following
code?
6,8,6
Here the code is given below. You have to identify the problem in the code.
while(i < 10) && (i > 24))
the test condition is always false
From the options given, you need to choose the option which is true for
the given code.
1 and 0
{}
What will be the correct syntax for initialization of a pointer ptr with string
"programming"?
char *ptr = "programming";
Which one of the given option is not a mode for reading/writing the data
from a file?
Get
Which of the following is the correct syntax to access the value of first
element of an array using pointer ptr?
*ptr[0]
Which of the following function call is "call by reference" for the following
function prototype?
func(&num);
The loop which is most suitable to be used when the number of iterations
is known is called ________.
for
What is the correct syntax to declare an array of size 10 of int data type?
int name[10];
The default mode for writing into a file using ofstream object is ________.
out
Identify the correct option which is used for calling the function float area
(int).
area(int num);
The ________ statement allows us to select from multiple choices based on
a set of fixed values for a given expression.
switch
To convert the value of one type into another type using built-in functions,
we include ________ header file.
stdlib.h
The keyword ________ is used to get some value back from a function.
return
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
Syntax of a union is identical to ________.
structure
We should use ________ for clarity and to force the order of evaluation in
an expression.
parenthesis ()
Which of the following is the starting index of an array in C++?
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++)
{
.....
}
}
Depends upon the statements in the inner loop's body
________ function give the position of the next character to be read from
that file.
tellp()
Which one of the following languages has been used to write the compiler
of "C" language?
C
A hierarchy of classes which are used to deal with console and disk files
are called ________.
Stream classes
________ stops execution at the line that contains error(s) in the code.
Interpreter
What will be the correct syntax for declaration of the following statement?
"ptr is a constant pointer to an integer"
const int *myptr;
suppose we have a file with name “mylife.txt” . what will be the correct
Syntax of file opening for input?
my file (“myfile.txt”. ios::in)
which of the following will be the most appropriate data type to store the
value 63.5 47?
Float
accessing a structure member the identifier to the left of the dot operator
is the name of----------
structural variable
Use of word processor for writing the code of a program is not good
because --------
It has less feature for writing code of a program
how many bytes and integer type pointer intptr will jump in memory if the
statement below is executed?
Intptr + = 2;
8
What will be the correct syntax for the following function call? float add
(int &);
add(x);
int counter = 0 ;
while(counter < 15)
cout << counter << “ ”;
counter++;
Infinite loop
Why we use "cin"?
To read data from keyboard