CS201 - Introduction To Programming
CS201 - Introduction To Programming
Objective Questions
Question
_________ will explain the function of a program.
1. Comments
2. Debugger
3. Compiler
4. Linker
Question
In computer systems there are mainly ___________ type of softwares.
1. 1
2. 2
3. 3
4. 4
Question
It is the job of __________ to transfer the executable code from hard disk to main memory.
1. Interpreter
2. Debugger
3. Linker
4. Loader
Question
In the given expression which operator will be evaluated first? 10 + (6 / 2) - 2 * 3?
1. +
2. -
3. /
4. *
Question
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);
1. 15
2. 17
3. 12
4. 11
Question
The most suitable data type for number 325.25 is ______.
1. char
2. int
3. short
4. float
Question
What will be the result of arithmetic expression 6+48/4*3?
1. 10
2. 40.5
3. 42
4. 41
Question
Which of the following will be the most appropriate data type to store the value 63.547?
1. Integer
2. Character
3. Short
4. Float
Question
____________ operators are the ones that require two operands on both sides of the operator.
1. Double
2. Tow sided
3. Binary
Question
When the logical operator && combines two expressions then the result will be true only when the both
expressions are ____________
1. Logical
2. Arithmetic
3. true
4. false
Answer: 3 Chapter No. 5
Question
< and > both are _________ operators.
1. Arithmetic
2. Relational
3. Logical
4. Mathematical
Question
!( x > 3) means in C++ that
1. x is greater than 3
3. x is less than 3
4. x is equal to 3
Question
!= operator is used to check whether the operand on the left-hand-side is __________ to the operand on
the right-hand-side.
3. Not equal
4. Approximately equal to
Question
When the if statement consists more than one statement then enclosing these statement in curly braces
is,
1. Not required
2. Good programming
3. Relevant
4. Must
1. x is less than 3
3. x is greater than 3
4. x is equal to 3
Question
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;
1. 68
2. 69
3. 70
4. 66
Question
A ___________ structure specifies that an action is to be repeated while some condition remains true.
1. Control
2. Logical
3. Repetition
4. Relational
Question
How many times the following loop will execute? int j = 3; while( j > 0) { cout << "Statements" << endl; j
-= 2; }
1. 0
2. 1
3. 2
4. 3
Question
Which of the following loops checks the test condition at the end of the loop?
1. While
2. Do-While
3. For
4. Nested Loop
Question
The operators ++ and -- are used to increment or decrement the value of a variable by ________.
1. 1
2. 2
3. 3
4. 4
Question
What will be the result of the expression j = i++; if initially j = 0 and i = 5?
1. 0
2. 5
3. 6
4. 4
Question
What will be the result of the expression k = ++m; if initially k = 0 and m = 4?
1. 0
2. 5
3. 6
4. 4
Question
What will be the result of the expression k = ++m; if initially k = 0 and m = 5?
1. 0
2. 5
3. 6
4. 4
Question
How many times the following do-while loop will execute? int k = 10; do { cout << "Statements" << endl;
k -= 2; } while(k>0);
1. 4
2. 5
3. 6
4. 7
Question
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; }
1. apple
2. apple
any fruit
3. apple
banana
mango
any fruit
4. none of above
Question
What will be the output of following code segment? for (int i = 2; i<10; i++){ if ( i == 5) continue; cout <<
i << "," ; }
1. 2,3,7,8,9
2. 2,3,4,6,7,8,9
3. 2,3,4
4. 4,6,7,8,9
1. if
2. goto
3. break
4. continue
Question
What is the output of the following code if the 2nd case is true switch (var) { case 'a':cout<<"apple"<
banana
banana
any fruit
banana
mango
any fruit
None of the given
Question
When the break statement is encountered in a loop's body, it transfers the control ________ from the
current loop.
1. Inside
2. Outside
3. To break statement
4. To continue statement
Question
Return type of a function that does not return any value must be _______.
1. char
2. int
3. void
4. double
1. " "
2. ()
3. []
4. {}
Question
Which of the function call is call by value for the following function prototype? float add(float);
1. add(&x);
2. add(x);
3. add(float x);
4. add(*x);
Question
Which of the function call is "call by value" for the following function prototype? float add(int);
1. add(&x);
2. add(x);
3. add(int x);
4. add(*x);
Question
Which of the following function call is "call by reference" for the following function prototype? int add (int
*);
1. add(&x);
2. add(int x);
3. add(x);
4. add(*x);
Question
Which of the following function call is "call by reference" for the following function prototype? float add
(float *);
1. add(&x);
2. add(float x);
3. add(x);
4. add(*x);
Question
________ of a variable means the locations within a program from where it can be accessed.
1. Data type
2. Visibility
3. Value
4. Reference
Question
Individual characters in a string stored in an array can be accessed directly using array _______.
1. superscript
2. script
3. subscript
4. value
Question
We can define a matrix as__________ array.
1. Sorted
2. Unsorted
3. Single dimensional
4. Multi dimensional
Question
A ________is an array of characters that can store number of character specified.
1. Char
2. String
3. Multidimensional array
4. Data type
Question
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?
1. array[3][4] = 6 ;
2. array[2][4] = 6 ;
3. array[4][3] = 6 ;
4. array[2][3] = 6 ;
Question
Transpose of a matrix means that when we interchange rows and columns___________.
Question
_________ is used as a dereferencing operator.
1. *
2. +
3. -
Question
The increment of a pointer depends on its___________.
1. variable
2. value
3. data type
Question
How many bytes an integer type pointer intPtr will jump in memory if the statement below is executed?
intPtr += 2 ;
1. 2
2. 4
3. 8
4. 12
Question
The statement cout << yptr will show the __________the yptr points to.
1. Value
2. memory address
3. Variable
Question
To read command-line arguments, the main() function itself must be given ___________ arguments.
1. 1
2. 2
3. 3
4. 4
Question
char **argv can be read as__________________.
1. pointer to pointer
2. pointer to char
Question
The parameter passed to isdigit() function is ____________variable.
1. Character
2. Boolean
3. Integer
4. Float
Question
What will be the output of the given code? #include #define MAX( A, B ) ((A) > (B) ? (A) : (B)) void main()
{ int i, x, y; x = 23; y = 45; i = MAX( x++, y++ ); // Side-effect: // larger value incremented twice cout <<
"x = " << x << " y = " << y << '\n'; }
1. x=23 y=45
2. x=24 y=46
3. x=24 y=47
4. x=22 y=47
Question
Symbolic constant PI can be defined as:
1. #define PI 3.14 ;
2. #define PI 3.14
3. #define PI=3.14
Question
getche() is a ________ function and defined in ___________ header file.
Question
We cannot use ________ pointer for storing and reading data from it.
1. 'NULL
2. integer
3. double
4. zero
Question
The dynamic memory allocation uses _________ whereas static memory allocation uses _________.
1. heap , stack
2. stack , lists
3. array , stack
4. classes , array
Question
Memory allocated from heap or free store ______________.
3. cannot be returned back unless freed explicitly using malloc and realloc
4. cannot be returned back unless freed explicitly using free and delete operators
Question
The main advantage of function overloading is ____________.
Question
You cannot overload the _____________ operator
1. ? :
2. *
3. /
4. ++
Question
Overloading means :
1. Using the same name to perform multiple tasks or different tasks depending on the situation.
2. Using the different name to perform multiple tasks or different tasks depending on the situation
3. Using the same name to perform multiple tasks or same tasks depending on the situation
4. Using the same name to perform difficult tasks or complex tasks and it does not depend on the situation
Question
Member functions of the class ________ main program.
4. are private to
Question
___________data isn't accessible by non-member functions or outside classes.
1. Public
2. private
3. Static
4. Globally declared
Question
The destructor is used to ____________.
1. allocate memory
2. deallocate memory
3. create objects
Question
An instance of a class is called __________.
1. structure
2. data type
3. object
4. member function
Question
The ________ is called automatically when an object destroys
1. destructor
2. constructor
3. main program
4. default constructor
Question
What will be the correct syntax for the following function call? float add (int &);
1. add(int x);
2. add(&x);
3. add(x);
4. add(*x);
Question
We can _____________references.
1. increment
2. decrement
3. reassign
Question
We cannot increment ____________.
1. pointers
2. arrays
3. references
4. variables
Question
We can ___________ pointer.
1. increment
2. decrement
3. reassign
Question
For binary member operators, operands on the ___________ drives (calls) the operation.
1. Left
2. Right
Course Codes