CS201 Introduction to Programming Solved MCQs
VU HELP CENTER : 03478749900
Question # 1 of 10 ( Start time: 06:31:50 PM ) Total Marks: 1
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
Question # 2 of 10 ( Start time: 06:32:48 PM ) Total Marks: 1
In while loop the loop counter must be initialized,
With in the loop
Before entering the loop
At the end of the loop
None of the given options
Question # 3 of 10 ( Start time: 06:33:15 PM ) Total Marks: 1
__________ of a variable means the locations within a program from where it can be accessed.
Data type
Visibility
Value
Reference
Question # 4 of 10 ( Start time: 06:33:49 PM ) Total Marks: 1
Switch support_______________ data.
Integer
Character
Float
Both integer and character
Question # 5 of 10 ( Start time: 06:34:31 PM ) Total Marks: 1
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
Question # 6 of 10 ( Start time: 06:35:13 PM ) Total Marks: 1
_________statement is used to terminate the processing of a particular case and exit from switch structure.
if
goto
break
continue
http://msdn.microsoft.com/en-us/library/wt88dxx6(v=vs.80).aspx
Question # 7 of 10 ( Start time: 06:35:32 PM ) Total Marks: 1
The most suitable data type for number 325.25 is ______.
char
int
short
float
Question # 8 of 10 ( Start time: 06:35:51 PM ) Total Marks: 1
X is an integer variable; what does X++ means,
Add 1 two times in X value
Add 1 in X value
Add 2 in X value
None of these
Question # 9 of 10 ( Start time: 06:36:12 PM ) Total Marks: 1
The operators ++ and –- are used to increment or decrement the value of a variable by ________
1
2
3
4
Question # 10 of 10 ( Start time: 06:36:34 PM ) Total Marks: 1
Which of the following loops checks the test condition at the end of the loop?
While
Do-While
For
Nested Loop
CS201 Introduction to Programming Solved MCQs
VU HELP CENTER : 03478749900
Question # 1 of 10 ( Start time: 12:31:13 PM ) Total Marks: 1
The result of 4%3 will be
2
1.5
1
1.33
Question # 2 of 10 ( Start time: 12:31:34 PM ) Total Marks: 1
While developing a program; should we think about the user interface?
Yes
No
Question # 3 of 10 ( Start time: 12:32:03 PM ) Total Marks: 1
Which of the following is the right syntax to declare a variable in C++?
VariableName Datatype;
DataType = VariableName;
DataType VariableName;
(DataType) VariableName;
Question # 4 of 10 ( Start time: 12:32:30 PM ) Total Marks: 1
What will be the resultant value of this expression x =17%3 ?
1
2
3
4
Question # 5 of 10 ( Start time: 12:32:50 PM ) Total Marks: 1
What will be the result of the expression k = ++m; if initially k = 0 and m = 5?
0
5
6
4
Question # 6 of 10 ( Start time: 12:33:08 PM ) Total Marks: 1
Function prototype is written,
Within main function
After the return statement in main
Before the return statement in main
Before call of that function
Question # 7 of 10 ( Start time: 12:34:02 PM ) Total Marks: 1
Switch statement can be used in place of _________ statement.
break
continue
Multiple if
goto
Question # 8 of 10 ( Start time: 12:34:46 PM ) Total Marks: 1
In while loop the loop counter must be initialized,
With in the loop
Before entering the loop
At the end of the loop
None of the given options
Question # 9 of 10 ( Start time: 12:35:28 PM ) Total Marks: 1
What logical error exists in the following arithmetic expression? X = 50 / ( 2 % 2 ) + 9
( ) parenthesis are not allowed in expressions
Division by zero will occur in this expression
Order of the expression is not according to rules
We can not use % operator in expressions
Question # 10 of 10 ( Start time: 12:36:06 PM ) Total Marks: 1
Loops are _______________ Structure.
Decision
Sequential
Repetition pg 560
None of the given options
CS201 Introduction to Programming Solved MCQs
VU HELP CENTER : 03478749900
Question # 1 of 10 Total Marks: 1
< and > both are _________ operators.
Arithmetic
Relational
Logical PG 258
Mathematical
Question # 2 of 10 Total Marks: 1
Find out the logical error in following lines of code. If (x = 10) cout << “x is 10”;
10 should be enclosed in quotations
There is no semicolon at the end of if condition
Assignment operator should not be used for comparison
Variable x should not be inside parenthesis
Question # 3 of 10 Total Marks: 1
What will be the result of the expression j = i++; if initially j = 0 and i = 5?
0
5
6
4
Question # 4 of 10 Total Marks: 1
Default mechanism of calling a function by passing it array is call by ________ and in case of passing variable is call by ________.
Reference, Reference
Reference, value PG154, 119
Value, Reference
Value, Value
Question # 5 of 10 Total Marks: 1
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
Question # 6 of 10 Total Marks: 1
________statement is used to terminate the processing of a particular case and exit from switch structure.
If
Goto
Break
Continue
http://msdn.microsoft.com/en-us/library/wt88dxx6(v=vs.80).aspx
Question # 7 of 10 Total Marks: 1
When the if statement consists of more than one statement then enclosing these statement in braces is _________.
Compulsory
Optional
Not required
Relevant
Question # 8 of 10 Total Marks: 1
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
1
Question # 9 of 10 Total Marks: 1
If we assign 2.06721 to an integer variable x, what will be the output if we print x using cout<< statement?
2
2.1
2.06
2.07
Question # 10 of 10 Total Marks: 1
__________ will be used for clarity and to force the order of evaluation in an expression.
” ”
() PG32
‘ ‘
[]
CS201 Introduction to Programming Solved MCQs
VU HELP CENTER : 03478749900
Value
Memory Address
Variabvle
None of given
Pointer to Pimter
Pointer to Char
Pointer to Pointer to Char (page 177)
None of given
‘argb’ and ‘argv’
‘argc’ and ‘argv’
‘argc’ and ‘argu’
None of Given
___________ Returns true if c is a digit and false otherwise.
int isalpha( int c )
int isalnum( int c )
int isxdigit( int c )
int isdigit( int c )
double dereference (page 175)
Single dereference
dereference
None of the given
_______________________ contains functions for manipulations of character data.
ctype.h
iostream.h
string.h
None of the given
*
+
–
None of the given
CS201 Introduction to Programming Solved MCQs
VU HELP CENTER : 03478749900
CS201 Introduction to Programming Solved MCQs
VU HELP CENTER : 03478749900
10.2 Q1: Which of the following statements will not produce a syntax error?
CS201 Introduction to Programming Solved MCQs
VU HELP CENTER : 03478749900
CS201 Introduction to Programming Solved MCQs
VU HELP CENTER : 03478749900
Section 11.1 Introduction
Which of the following is true about streams?
A. It is a sequence of bytes
B. It is an ordered sequence
C. All bytes can go through the stream simultaneously
D. Bytes that enters first into the stream will go out at last
A only
C only
A and B
A and D
Stream is a sequence of bytes. It is an ordered sequence. Let’s compare it with the door example. The person who enters first will go out of the door first. The person who enters behind someone will go out behind that person. Similarly streams are also ordered sequence. The thing that enters first into the stream will go out first. You should think streams as ordered sequence of bytes. Byte is a unit of measure. A byte can store one character, so you can think of an ordered sequence of characters.
CS201 Introduction to Programming Solved MCQs
VU HELP CENTER : 03478749900
1- Memory allocated from heap or free store _____________________.
Select correct option:
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
2- Once the _______________ are created, they exist for the life time of the program
Select correct option:
local variables
non static variables
static variables
automatic variables
Once the static variables are created, they exist for the life of the program. They do not die. So returning their reference is all right.3- The members of a class declared with the keyword struct are _____________by default.
Select correct option:
static
private
protected
public.
The members of a class declared with the keyword struct are public by default. A structure is inherited publicly by default.
www.vuzs.info
4- If the memory in the free store is not sufficient ____________________.
Select correct option:
malloc function returns 1
malloc function returns 0
malloc functions returns NULL pointer
malloc function returns free space
if the memory in the free store is not sufficient enough to fulfill the request. malloc() function returns NULL pointer if the memory is not enough. In C++, 0 is returned instead of NULL pointer.
5. This reference to a variable can be obtained by preceding the identifier of a variable with ________________.
Select correct option:
dot operator
ampersand sign &
^ sign
- operator
6- Once an object is declared as a friend, _________________________.
Select correct option:
it has access to all non-public members as if they were public
it has access to public members only
it has no access to data members of the class
it has to protected data members only
- Friend declarations introduce extra coupling between classes
- Once an object is declared as a friend, it has access to all non-public members as if they were public
- Access is unidirectionalIf B is designated as friend of A, B can access A’s non-public members; A cannot access B’s
- A friend function of a class is defined outsideof that class’s scope
7- Reference variables must _________________.
Select correct option:
not be initialized after they are declared
be initialized after they are declared
contain integer value
contain zero value
8- If the request of new operator is not fulfilled due to insufficient memory in the heap ____________________.
Select correct option:
the new operator returns 2
the new operator returns 1
malloc functions returns NULL pointer
malloc function returns free space
9- Reference is not really an address it is ______________.
Select correct option:
a synonym
an antonym
a value
a number
10- If the request of new operator is not fulfilled due to insufficient memory in the heap ____________________.
Select correct option:
the new operator returns 2
the new operator returns 1
the operator returns 0
free operator returns nothing
11- Functions declared with the _______________ specifier in a class member list are called friend functions of that class.
Select correct option:
protected
private
Public
friend
Functions declared with the friend specifier in a class member list are called friend functions of that class. Classes declared with the friend specifier in the member list of another class are called friend classes of that class.
12- public or private keywords can be ____________
Select correct option:
written only for once in the class or structure declaration
written multiple times in the class or structure declaration
written only twice in the class declaration
written outside the class
good practice is to write public or private keywords only once in the class or structure declaration, though there is no syntactical or logical problem in writing them multiple times.
13-The friend keyword provides access _____________.
Select correct option:
in one direction only
in two directions
to all classes
to the data members of the friend class only
The friend keyword provides access in one direction only. This means that while OtherClass is a friend of ClassOne, the reverse is not true.
14- References cannot be uninitialized. Because it is impossible to _______________
Select correct option:
reinitialize a pointer
reinitialize a reference
initialize a NULL pointer
cast a pointer
http://en.wikipedia.org/wiki/Reference_(C%2B%2B)
References cannot be uninitialized. Because it is impossible to reinitialize a reference,
15- new operator can be used for ______________.
Select correct option:
only integer data type
only char and integer data types
integer , float, char and double data types
dot operator
Similarly, new operator can be used for other data types like char, float and double etc.
16- The destructor is used to ______________.
Select correct option:
allocate memory
deallocate memory
create objects
allocate static memory
16- If we want to allocate memory to an array of 5 integers dynamically, the syntax will be _____________.
Select correct option:
int *iptr ; iptr = new int[5] ;
integer iptr** ; iptr= new int[5]
int iptr ; iptr= int [5]
iptr= new[5]
17- Memory allocated from heap or free store _____________________.
Select correct option:
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
18- Operator overloading is to allow the same operator to be bound to more than one implementation, depending on the types of the _________.
Select correct option:
Compilers
Operands
Function names
Applications
Operator overloading is to allow the same operator to be bound to more than one
implementation, depending on the types of the operands.
19- The operator to free the allocated memory using new operator is ________________.
Select correct option:
free
del
delete
remove
The operator to free the allocated memory using new operator is delete. So whenever,
we use new to allocate memory, it will be necessary to make use of ‘delete’ to deallocate
the allocated memory.
20- The concept of friend function negates the concept of _________________.
Select correct option:
inheritance
polymorphism
persistence
encapsulation
CS201 Introduction to Programming Solved MCQs
VU HELP CENTER : 03478749900
Functions declared with the _______________ specifier in a class member list are called friend functions of that class.
protected
private
public
friend
Functions declared with the friend specifier in a class member list are called friend functions of that class. Classes declared with the friend specifier in the member list of another class are called friend classes of that class.
Public or private keywords can be ____________
written only for once in the class or structure declaration
written multiple times in the class or structure declaration
written only twice in the class declaration
written outside the class
good practice is to write public or private keywords only once in the class or structure declaration, though there is no syntactical or logical problem in writing them multiple times.
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 friend keyword provides access in one direction only. This means that while OtherClass is a friend of ClassOne, the reverse is not true.
References cannot be uninitialized. Because it is impossible to _______________
reinitialize a pointer
reinitialize a reference
initialize a NULL pointer
cast a pointer
http://en.wikipedia.org/wiki/Reference_(C%2B%2B)
References cannot be uninitialized. Because it is impossible to reinitialize a reference,
new operator can be used for ______________.
only integer data type
only char and integer data types
integer , float, char and double data types
dot operator
Similarly, new operator can be used for other data types like char, float and double etc.
The destructor is used to ______________.
allocate memory
deallocate memory
create objects
allocate static memory
Reference is not really an address it is ______________.
a synonym
an antonym
a value
a number
Difference Between References and Pointers
The reference in a way keeps the address of the data entity. But it is not really an address it is a synonym,
If we want to allocate memory to an array of 5 integers dynamically, the syntax will be _____________.
int *iptr ; iptr = new int[5] ;
integer iptr** ; iptr= new int[5]
int iptr ; iptr= int [5]
iptr= new[5]
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
The memory allocated from free store or heap is a system resource and is not returned back to the system unless explicitly freed using delete or free operators.
Operator overloading is to allow the same operator to be bound to more than one implementation, depending on the types of the _________.
Compilers
Operands
Function names
Applications
Operator overloading is to allow the same operator to be bound to more than one implementation, depending on the types of the operands.
The operator to free the allocated memory using new operator is ________________.
free
del
delete
remove
The operator to free the allocated memory using new operator is delete. So whenever, we use new to allocate memory, it will be necessary to make use of ‘delete’ to deallocate the allocated memory.
suppose we have int y[10]; To access the 4th element of the array we write_______
y[4];
y[3];
y[2];
none of given
From the following; which one is the range of Random number generator function rand()?
0 – 32768
1 – 32768
0 – 32767
1 – 32767
From following; which one is the correct syntax of an array initialize: Array size is 10 and it is of double data type to value 0?
arr[10] = {0.0};
double arr[10]= 0.0;
double arr[10] = {0.0};
double arr[] = 0.0;
The string in the array is terminated by a_____
zero
nil
null
one
CS201 Introduction to Programming Solved MCQs
VU HELP CENTER : 03478749900
In C/C++; by default arguments are passed by_____to a function.
Reference
Value
Type
Data
1
char name [] = “Hello World” ; In the above statement, a memory of_______characters will be allocated
13
11
12
10
_______Keyword is used to return some value from a function.
break
return
continue
goto
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);
The increment of a pointer depends on its_________.
variable
value
data type
None of the given
The ASCHI code of null character is_________
000
010
111
110
Pointers are a special type of __________in which a memory address is stored
variables
Location
Characters
None of the given
just for copy paste
CS201 Introduction to Programming Solved MCQs
VU HELP CENTER : 03478749900
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
Pointers store the ____________________
value of a variable
memory address
characters
None of the given
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);
The name of the array is a constant pointer which contains the memory address of the ____________of the array.
first element
Last element
second element
None of the given
array name always contains the memory address of the ___________of the array
entire elements
last element
first element
None of the given
At the___________, we try to break up the problem into functional units
analysis phase
design phase
Implementation phase
None of the given
1. Each pass through a loop is called a/an
[a] enumeration
[b] iteration
[c] culmination
[d] pass through
2. Which looping process checks the test condition at the end of the loop?
[a] for
[b] while
[c] do-while
[d] no looping process checks the test condition at the end
3. A continue statement causes execution to skip to
[a] the return 0; statement
[b] the first statement after the loop
[c] the statement following the continue statement
[d] the next iteration of the loop
4. In a group of nested loops, which loop is executed the most number of times?
[a] the outermost loop
[b] the innermost loop
[c] all loops are executed the same number of times
[d] cannot be determined without knowing the size of the loops
5. The statement i++; is equivalent to
[a] i = i + i;
[b] i = i + 1;
[c] i = i – 1;
[d] i –;
6. Which looping process is best used when the number of iterations is known?
[a] for
[b] while
[c] do-while
[d] all looping processes require that the iterations be known
7. What’s wrong? for (int k = 2, k <=12, k++)
[a] the increment should always be ++k
[b] the variable must always be the letter i when using a for loop
[c] there should be a semicolon at the end of the statement
[d] the commas should be semicolons
8. What’s wrong? while( (i < 10) && (i > 24))
[a] the logical operator && cannot be used in a test condition
[b] the while loop is an exit-condition loop
[c] the test condition is always false
[d] the test condition is always true
9. If there is more than one statement in the block of a for loop, which of the following must be placed at the beginning and the ending of the loop block?
[a] parentheses ( )
[b] braces { }
[c] brackets [ ]
[d] arrows < >
10. What’s wrong? (x = 4 && y = 5) ? (a = 5) ; (b = 6);
[a] the question mark should be an equal sign
[b] the first semicolon should be a colon
[c] there are too many variables in the statement
[d] the conditional operator is only used with apstrings