In the name of ALLAH, the most beneficient, the most merciful

Introduction to Programming (CS201)

Multiple Choice Questions (MCQs)

 

Objective Questions

Question

_________ will explain the function of a program.

  1. Comments
  2. Debugger
  3. Compiler
  4. Linker

Answer: 1 Chapter No. 1 

Question

In computer systems there are mainly ___________ type of softwares.

  1. 1
  2. 2
  3. 3
  4. 4

Answer: 2 Chapter No. 2 

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

Answer: 4 Chapter No. 2 

Question

In the given expression which operator will be evaluated first? 10 + (6 / 2) - 2 * 3?

  1. +
  2. -
  3. /
  4. *

Answer: 3 Chapter No. 3 

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

Answer: 2 Chapter No. 3 

Question

The most suitable data type for number 325.25 is ______.

  1. char
  2. int
  3. short
  4. float

Answer: 4 Chapter No. 3 

Question

What will be the result of arithmetic expression 6+48/4*3?

  1. 10
  2. 40.5
  3. 42
  4. 41

Answer: 3 Chapter No. 3 

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

Answer: 4 Chapter No. 3 

Question

____________ operators are the ones that require two operands on both sides of the operator.

  1. Double
  2. Tow sided
  3. Binary
  4. None of the given

Answer: 3 Chapter No. 3 

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

Answer: 2 Chapter No. 5 

Question

!( x > 3) means in C++ that

  1. x is greater than 3
  2. x is less than or equal to 3
  3. x is less than 3
  4. x is equal to 3

Answer: 2 Chapter No. 5 

Question

!= operator is used to check whether the operand on the left-hand-side is __________ to the operand on the right-hand-side.

  1. Less than or equal
  2. Greater than or equal
  3. Not equal
  4. Approximately equal to

Answer: 3 Chapter No. 5 

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

Answer: 4 Chapter No. 5 

Question

!( x < 3) means in C++ that

  1. x is less than 3
  2. x is greater than or equal to 3
  3. x is greater than 3
  4. x is equal to 3

Answer: 2 Chapter No. 5 

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

Answer: 3 Chapter No. 5 

Question

A ___________ structure specifies that an action is to be repeated while some condition remains true.

  1. Control
  2. Logical
  3. Repetition
  4. Relational

Answer: 1 Chapter No. 6 

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

Answer: 3 Chapter No. 6 

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

Answer: 3 Chapter No. 7 

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

Answer: 2 Chapter No. 7 

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

Answer: 2 Chapter No. 7 

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

Answer: 3 Chapter No. 7 

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

Answer: 3 Chapter No. 7 

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

Answer: 2 Chapter No. 7 

Question

The operators ++ and -- are used to increment or decrement the value of a variable by ________.

  1. 1
  2. 2
  3. 3
  4. 4

Answer: 1 Chapter No. 7 

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
  • Answer: 3 Chapter No. 8 

    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

    Answer: 3 Chapter No. 8 

    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

    Answer: 2 Chapter No. 8 

    Question

    _________statement is used to terminate the processing of a particular case and exit from switch structure.

    1. if
    2. goto
    3. break
    4. continue

    Answer: 3 Chapter No. 8 

    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

    Answer: 2 Chapter No. 8 

    Question

    Return type of a function that does not return any value must be _______.

    1. char
    2. int
    3. void
    4. double

    Answer: 3 Chapter No. 9 

    Question

    ______ will be used for enclosing function statements into a block.

    1. " "
    2. ()
    3. []
    4. {}

    Answer: 4 Chapter No. 9 

    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);

    Answer: 2 Chapter No. 9 

    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);

    Answer: 2 Chapter No. 9 

    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);

    Answer: 1 Chapter No. 10 

    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);

    Answer: 1 Chapter No. 10 

    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

    Answer: 2 Chapter No. 10 

    Question

    Individual characters in a string stored in an array can be accessed directly using array _______.

    1. superscript
    2. script
    3. subscript
    4. value

    Answer: 3 Chapter No. 12 

    Question

    We can define a matrix as__________ array.

    1. Sorted
    2. Unsorted
    3. Single dimensional
    4. Multi dimensional

    Answer: 4 Chapter No. 12 

    Question

    A ________is an array of characters that can store number of character specified.

    1. Char
    2. String
    3. Multidimensional array
    4. Data type

    Answer: 2 Chapter No. 12 

    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 ;

    Answer: 4 Chapter No. 12 

    Question

    Transpose of a matrix means that when we interchange rows and columns___________.

    1. the first row becomes the Last column
    2. the first row becomes the first column
    3. the Last row becomes the first column
    4. the first column becomes the first row

    Answer: 2 Chapter No. 13 

    Question

    _________ is used as a dereferencing operator.

    1. *
    2. +
    3. -
    4. None of the above

    Answer: 1 Chapter No. 14 

    Question

    The increment of a pointer depends on its___________.

    1. variable
    2. value
    3. data type
    4. None of the given

    Answer: 3 Chapter No. 15 

    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

    Answer: 3 Chapter No. 15 

    Question

    The statement cout << yptr will show the __________the yptr points to.

    1. Value
    2. memory address
    3. Variable
    4. None of the given

    Answer: 2 Chapter No. 15 

    Question

    To read command-line arguments, the main() function itself must be given ___________ arguments.

    1. 1
    2. 2
    3. 3
    4. 4

    Answer: 2 Chapter No. 16 

    Question

    char **argv can be read as__________________.

    1. pointer to pointer
    2. pointer to char
    3. pointer to pointer to char
    4. None of the given

    Answer: 3 Chapter No. 16 

    Question

    The parameter passed to isdigit() function is ____________variable.

    1. Character
    2. Boolean
    3. Integer
    4. Float

    Answer: 3 Chapter No. 17