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

Introduction to Programming (CS201)

Multiple Choice Questions (MCQs)

Objective Questions

  1. ________ of a variable means the locations within a program from where it can be accessed.

    1. Data type
    2. Visibility
    3. Value
    4. Reference
  2. What will be the output of following code?

    int i = 1;

    while(i<10){

    if(i%2 == 0)

    cout<<i<<" ";

    i++;

    }

    1. 2 4 6 10
    2. 1 3 5 7
    3. 2 4 6 8
    4. 2 4 8 10
  3. Which of the following is not an example of int data type?

    1. 0
    2. -32
    3. 65531
    4. -4
  4. The condition in loop should be a(n) ________.

    1. Constant Expression
    2. Boolean Expression
    3. Primary Expression
    4. Arithmetic Expression
  5. If the condition is not made false in while loop, what will happen?

    1. Loop will become infinite.
    2. Program will not run at all.
    3. Program will terminate early.
    4. Syntax errors occur.
  6. When an array element is passed to a function, it is passed by ________.

    1. reference
    2. data type
    3. value
    4. data
  7. The keyword ________ is used to get some value back from a function.

    1. return
    2. break
    3. continue
    4. goto
  8. To read command-line arguments, the main() function itself must be given ________ arguments.

    1. 1
    2. 2
    3. 3
    4. 4
  9. !( 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
  10. In case of single dereferencing, the value of the ________ is the address of the ________.

    1. pointer, variable
    2. pointer, constant
    3. variable, pointer
    4. constant, pointer
  11. To avoid dangling reference, don't return ________.

    1. the reference of a local variable from the function
    2. the reference of a global variable from the function
    3. the reference of a static variable from the function
    4. the reference of a private data member from the function
  12. Which of the following expression is correct in C/C++ language?

    1. X = X + 3
    2. 3 = X + 3
    3. Y + X = 7
    4. X + 5 = Y + 7
  13. ________ operator is used to pass the address of a variable in call by reference method.

    1. %
    2. +
    3. @
    4. &
  14. What will be the correct syntax for declaration of the following statement?
    "ptr is a constant pointer to an integer"

    1. const * int myptr;
    2. const int *myptr;
    3. int const *ptr;
    4. int *const ptr;
  15. Which one of the symbol is used to represent a decision in a flow chart?

  16. Which of the following data types will be assumed if no data type is specified with constant?

    1. short
    2. float
    3. int
    4. double
  17. What will be the output of following code?


    int x = 15;
    int y = 10;
    int z = 5;
    cout<< x * x - 4 * y * z;

    1. 25
    2. -25
    3. -5
    4. 5
  18. NULL has been defined in ________ header file.

    1. Iostream.h
    2. Stdlib.h
    3. Stdio.h
    4. String.h
  19. Whenever we use a library function or a predefined object or macro, we need to use a ________.

    1. source file
    2. object file
    3. header file
    4. exe file
  20. 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?

    1. m[2][3] = 5;
    2. m[3][2] = 5;
    3. m[1][2] = 5;
    4. m[2][3] = '5';
  21. For binary member operators, operands on the ________ drives (calls) the operation.

    1. Left
    2. Right
    3. Both left and right
    4. None of the given
  22. Individual characters in a string stored in an array can be accessed directly using array ________.

    1. superscript
    2. script
    3. subscript
    4. value
  23. The coding of a program is translated into machine language by ________.

    1. Debugger
    2. Compiler
    3. Loader
    4. Linker
  24. The most suitable data type for number 325.25 is ________.

    1. char
    2. int
    3. short
    4. float
  25. In C/C++, the default command line arguments passed to the main function are ________.

    1. float argc, char **argv
    2. int argc, char **argv
    3. int *argc, char *argv
    4. int argc, float **argv
  26. ________ of a function is also known as signature of a function.

    1. Definition
    2. Declaration
    3. Calling
    4. Invoking
  27. 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;
    }

    1. mango
    2. mango
      any fruit
    3. apple
    4. None of the given
  28. The compiler of C language is written in ________ language.

    1. JAVA
    2. BASIC
    3. FORTRAN
    4. C
  29. TWAIN stands for ________.

    1. Technology With An Interesting Name
    2. Technology Without An Informative Name
    3. Technology Without An Interesting Name
    4. Technology With An Informative Name
  30. Select the correct way to assign the address of first element of array to pointer?

    1. int *ptr = &data[1];
    2. int *ptr = &data;
    3. int *ptr = data;
    4. int *ptr = data[0];
  31. If a function has been declared but not defined before its function call then it is termed as ________.

    1. logical error
    2. syntax error
    3. run time error
    4. program time error
  32. 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 ;
  33. While programming, it is good to provide an easy to understand and easy to use interface; this programming skill is called ________.

    1. scalability
    2. usability
    3. reliability
    4. sustainability
  34. The only operator that the compiler overloads for user define data type by default is

    1. Plus (+) operator
    2. MInus (-) operator
    3. Assignment (=) operator
    4. Equal (==) operator
  35. An instance of a class is called ________.

    1. structure
    2. data type
    3. object
    4. member function
  36. The memory address of the first element of an array is called ________.

    1. floor address
    2. foundation address
    3. first address
    4. base address
  37. 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);

    }

    1. 49
    2. 99
    3. 89
    4. 81
  38. 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
  39. ________ is the pointer which determines the position in a file from where the next read operation occurs.

    1. put
    2. seek
    3. get
    4. tell
  40. How many elements are stored in the following?
    int matrix [4][5];

    1. 9
    2. 20
    3. 25
    4. 10
  41. Object code is machine code but it is not ________ and ________.

    1. relocatable, executable
    2. faster, efficient
    3. compiled, debugged
    4. tested, compiled
  42. The first parameter of operator function for << operator ________.

    1. Must be passed by value
    2. Must be passed by reference
    3. Can be passed by value or reference
    4. Must be object of class
  43. Once we have defined a symbolic constant value using #define, that value ________ during program execution

    1. can be changed
    2. cannot be changed
    3. varies
    4. becomes zero
  44. A reference cannot be NULL it has to point a data type.

    1. True
    2. False
  45. ________ will return the number of bytes reserved for a variable or data type.

    1. sizeof operator
    2. free operator
    3. void pointer
    4. new operator
  46. Which function is used to locate the first occurance of a character in any string?

    1. strchr()
    2. strstr()
    3. strtok()
    4. strlen()
  47. With user data type variables (Objects) self assignment can produce

    1. Link error
    2. Run time error
    3. Syntax error
    4. Logical error
  48. Consider the following code, the printed value will be converted into:
    int n=10;
    cout <<oct<<n;

    1. Base 8
    2. Base 2
    3. Base 10
    4. Decimal number system
  49. The second parameter of operator function for >> operator must always be passed

    1. By reference
    2. Function takes no argument
    3. By value
    4. None of the given
  50. if
    int sum = 54;
    Then the value of the following statement is
    sum = sum - 3;

    1. 52
    2. 50
    3. 51
    4. 57
  51. 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
  52. Here the code is given below. You have to identify the problem in the code.

    while(i < 10) && (i > 24))

    1. the logical operator && cannot be used in test condition
    2. the while loop is an exit-condition loop
    3. the test condition is always true
    4. the test condition is always false
  53. ________ statement is used to terminate the processing of a particular case and exit from switch structure.

    1. if
    2. goto
    3. break
    4. continue
  54. In the given expression which operator will be evaluated first? 10 + (6 / 2) - 2 * 3?

    1. +
    2. -
    3. /
    4. *
  55. Constructor is special type of function :

    1. which has no return type
    2. which returns NULL pointer
    3. which returns zero
    4. which returns integer type data
  56. Structure use ________ allocation.

    1. Queue
    2. Heap
    3. Cache
    4. Stack
  57. If the request of new operator is not fulfilled due to insufficient memory in the heap ________.

    1. the new operator returns 2
    2. the new operator returns 1
    3. the operator returns 0
    4. free operator returns nothing
  58. Syntax of a union is identical to ________.

    1. structure
    2. class
    3. function
    4. loop
  59. ________ data type can operate on modulus operator.

    1. int
    2. float
    3. char
    4. double
  60. 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
  61. In Flow Chart, flow of control is represented by ________.

    1. Rectangle
    2. Circle
    3. Diamomd
    4. Arrow
  62. The loop which is most suitable to be used when the number of iterations is known is called ________.

    1. for
    2. while
    3. do-while
    4. all looping processes require that the iterations be known.
  63. In C/C++, the algebraic expression (b2-4ac) / 2a can be written as:

    1. (b*b - 4*a*c) / (2*a)
    2. b*b - 4*a*c / (2*a)
    3. b*b - 4*a*c / 2*a
    4. b*b - (4*a*c) / 2*a
  64. Array is a data structure that stores ________.

    1. Memory addresses
    2. Variables
    3. Data type
    4. Data
  65. To convert the value of one type into another type using built-in functions, we include ________ header file.

    1. conio.h
    2. stdlib.h
    3. iostream.h
    4. string.h
  66. 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
  67. Learning "how to program" is important, because it develops ________ and problem-solving abilities.

    1. Analytical
    2. Writing
    3. Listening
    4. Reading
  68. We should use ________ for clarity and to force the order of evaluation in an expression.

    1. brackets []
    2. parenthesis ()
    3. curly braces {}
    4. quotation marks " "
  69. Which of the following structure is correct for WHILE loop?

    1. While (start; condition; end)
    2. While (start; condition)
    3. While (condition; end)
    4. While (condition)
  70. !( 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
  71. In C/C++, the string constant is enclosed in ________.

    1. curly braces { }
    2. parentheses( )
    3. single quotes ' '
    4. double quotes " "
  72. Switch statement deals with ________ type of data.

    1. Integer
    2. Float
    3. Character
    4. Both Integer and Character
  73. The members of a class declared with the keyword struct are ________ by default.

    1. static
    2. Private
    3. protected
    4. public
  74. Word processor is a type of a/an ________.

    1. operating system
    2. application software
    3. device driver
    4. utility software
  75. C++ was developed by ________.

    1. Charles Babbage
    2. Graham Bell
    3. Bejarne Stroustrup
    4. Von Nuemann
  76. ________ is a substitute of multiple if statement.

    1. if. . .elseif statement
    2. Continue statement
    3. Break statement
    4. Default statement
  77. Which one of the following languages has been used to write the compiler of "C" language?

    1. Java
    2. Fortran
    3. Basic
    4. C
  78. The microsoft word document (.doc) is a kind of ________.

    1. Sequential File
    2. Random Access File
    3. Binary Access File
    4. Executable File
  79. A ________ structure specifies that an action is to be repeated while some condition remains true.

    1. Control
    2. Logical
    3. Repetition
    4. Relational
  80. The statement cout << yptr will show the ________ the yptr points to.

    1. Value
    2. memory address
    3. variable
    4. None of the given
  81. Which one of the given option is not a mode for reading/writing the data from a file?

    1. in
    2. out
    3. trunc
    4. get
  82. C is a/an ________ language.

    1. low level
    2. object based
    3. object oriented
    4. function oriented
  83. ________ stops execution at the line that contains error(s) in the code.

    1. Compiler
    2. Debugger
    3. Interpreter
    4. Linker
  84. The purpose of using cout<< is to ________.

    1. Display information on the screen
    2. Read the data from keyboard
    3. Read the data from a file
    4. Write into a file
  85. ________ function give the position of the next character to be read from that file.

    1. tellp()
    2. tellg()
    3. seekg()
    4. seekp()
  86. ________ must be included to use stream manipulation in your code.

    1. conio.h
    2. iostream
    3. stdlib.h
    4. iomanip
  87. It is the job of ________ to transfer the executable code from hard disk to main memory.

    1. interpreter
    2. Debugger
    3. Linker
    4. Loader
  88. For console input and output we use ________.

    1. conio.h header file
    2. stdlib.h header file
    3. process.h header file
    4. getch.h header file
  89. A class can be declared as a ________ of other class.

    1. member
    2. member function
    3. friend
    4. part
  90. The ________ is called automatically when an object destroys

    1. destructor
    2. constructor
    3. main program
    4. default constructor
  91. getche() is a ________ function and defined in ________ header file.

    1. user-define function , conio.h
    2. built-in function , conio.h
    3. built-in function, stlib.h
    4. built -in function, iostream.h
  92. A pointer is ________.

    1. the address of a variable
    2. an indication of the variable to be accessed next
    3. a variable for storing address
    4. the data type of an address variable
  93. 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.

    1. upper case alphabets
    2. lower case alphabets
    3. double underscore
    4. None of the given
  94. The operators ++ and -- are used to increment or decrement the value of a variable by ________.

    1. 3
    2. 2
    3. 1
    4. 4
  95. ________ data isn't accessible by non-member functions or outside classes.

    1. Public
    2. private
    3. Static
    4. Globally declared
  96. dec, hex, oct are all ________.

    1. Member functions
    2. Objects of input/output streams
    3. Parameterized manipulators
    4. Non-parameterized manipulators
  97. Which of the following is not a reserved word in C/C++?

    1. int
    2. float
    3. double
    4. sum
  98. Which of the following values are used in C/C++ to represent true and false?

    1. 1 and 0
    2. 1 and -1
    3. 11 and 00
    4. any numerical value
  99. A 2D array multi[5][10] can be accessed using the array name as **multi, this technique is called ________.

    1. Single referencing
    2. Single dereferencing
    3. Double referencing
    4. Double dereferencing
  100. How many dimensions does n-dimensional array has?

    1. n dimensions
    2. 2n dimensions
    3. (n+1) dimensions
    4. (n-1) dimensions
  101. 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++)
    {
    . . . . .
    }
    }

    1. Outer loop
    2. Inner loop
    3. Both loops run equal number of times
    4. Depends upon the statements in the inner loop's body
  102. Function prototype is written,

    1. Within main function
    2. After the return statement in main
    3. Before the return statement in main
    4. Before call of that function
  103. 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
  104. Body of any function is enclosed within ________.

    1. { }
    2. ( )
    3. [ ]
    4. " "
  105. 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?

    1. 0x22f221
    2. 0x22f222
    3. 0x22f223
    4. 0x22f224
  106. Within the statement obj1=obj2; obj1 will call the assignment operator function and obj2 will be passed as an argument to function.

    1. True
    2. False
  107. Matrix is defined as ________.

    1. Single dimensional array
    2. Multi-dimensional array
    3. Vector product
    4. Scalar product
  108. The function write() takes ________ as parameter(s).

    1. String of pointer type
    2. String of variable lengths, no. of bytes to be read and flags
    3. Poimter array of characters and a delimiter
    4. String and no. of bytes to be written
  109. Once the ________ are created, they exist for the life time of the program.

    1. local variables
    2. non static variables
    3. static variables
    4. automatic variables
  110. Which of the following syntax is best used to delete an array of 5 objects named 'string' allocated using new operator.

    1. delete string;
    2. delete []string;
    3. delete string[];
    4. delete string[5];
  111. When an operator function is defined as member function for a Unary operator then the number of extra arguments it takes is/are,

    1. Zero
    2. Two
    3. One
    4. N arguments
  112. What is the function of the following statement to delete an array of 5 objects named 'arr' allocated using new operator?
    delete arr;

    1. Results into syntax error
    2. Deletes all the objects of array
    3. Do not delete any object
    4. Deletes only one object of array
  113. The parameter passed to isdigit() function is ________.

    1. a character variable
    2. a boolean variable
    3. an integer variable
    4. a character string
  114. Identify the correct option which is used for calling the function float area (int).

    1. area(&num);
    2. area(num);
    3. area(int num);
    4. area(*num);
  115. != 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
  116. ________ operators are the ones that require only one operator to work.

    1. Unit
    2. Unary
    3. Single
    4. None of the given
  117. 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
  118. If any break statement is missed in switch statement then ________.

    1. compiler will give error
    2. this may cause a logical error
    3. no effect on program
    4. program stops its execution
  119. 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
  120. When a variable is defined as static in a class then ________.

    1. Separate copy of this variable is created for each object
    2. Only one copy is created for all objects of this class
    3. A copy of this variable is created for only static objects
    4. None of the given
  121. 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);
  122. To access rand(), which library is required to be included in program?

    1. conio.h
    2. stdio.h
    3. stdlib.h
    4. iostream.h
  123. Which of the following C++ statements is used take input from the user?

    1. cin
    2. cerr
    3. cout
    4. cget
  124. Return type of a function that does not return any value must be ________.

    1. char
    2. int
    3. void
    4. double
  125. To access the data members of structure, ________ is used.

    1. Logical operator
    2. Dereference operator
    3. Dot operator
    4. Address operator
  126. Operating System is a type of a/an ________.

    1. application software
    2. system software
    3. computer language
    4. interpreter
  127. The correct syntax of do-while loop is ________.

    1. (condition) while; do {statements;};
    2. {statements;} do-while();
    3. while(condition); do {statements;};
    4. do {statements;} while (condition);
  128. We can define a matrix as ________ array.

    1. Sorted
    2. Unsorted
    3. Single dimensional
    4. Multi dimensional
  129. What will be the correct syntax for initialization of a pointer ptr with string "programming"?

    1. char ptr = 'programming';
    2. char *ptr = "programming";
    3. char *ptr = 'programming';
    4. *ptr = "programming";
  130. 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?

    1. 0x22f231
    2. 0x22f234
    3. 0x22f226
    4. 0x22f238
  131. A record is a group of related ________.

    1. Data
    2. Fields
    3. Bytes
    4. Files
  132. Which one of the below functions is not included in ctype.h header file?

    1. isdigit(int c)
    2. isxdigit(int c)
    3. tolower(int c)
    4. getdigit(int c)
  133. Automatic variables are created on ________.

    1. Heap
    2. Free store
    3. Static storage
    4. stack
  134. The destructor is used to ________.

    1. allocate memory
    2. deallocate memory
    3. create objects
    4. allocate static memory
  135. 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
  136. Symbolic constant PI can be defined as:

    1. #define PI 3.14 ;
    2. #define PI 3.14
    3. #define PI=3.14
    4. # include pi= 3.14
  137. 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

    1. Heap
    2. Stack
    3. Buffer
    4. Cache
  138. The friend keyword provides access ________.

    1. in one direction only
    2. in two directions
    3. to all classes
    4. to the data members of the friend class only
  139. Which of the following function call is "call by reference" for the following function prototype?

    1. func(int &num);
    2. func(&num);
    3. func(*num);
    4. func(num);
  140. Which of the following if missing would result in infinite recursion in case of recursive function?

    1. Recursive call
    2. Base case
    3. Function parameters
    4. Local variables
  141. We must include the header file ________ to convert the value of one type into another type using built-in functions.

    1. conio.h
    2. stdlib.h
    3. string.h
    4. iostream.h
  142. Which of the following is the starting index of an array in C++?

    1. 0
    2. 1
    3. -1
    4. 2
  143. Constructor is a special function, called whenever we ________.

    1. create a function
    2. instantiate an object of a class
    3. destroy an object
    4. create a class
  144. 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);
  145. When operator function is implemented as member function then return type of function ________.

    1. Must be an object of same class
    2. Must be user-defined data type
    3. Must be built-in data type
    4. Can be any data type
  146. Symbolic constant PI can be defined as:

    1. #define PI 3.14;
    2. #define PI 3.14
    3. #define PI=3.14
    4. # include pi=3.14
  147. ________ variables are defined in the main.

    1. Global
    2. Dynamic
    3. Local
    4. All
  148. Encapsulation means ________.

    1. that the data of a class cannot be accessed from outside
    2. that the data of a class can be accessed from outside
    3. the data becomes public
    4. that the data can be accessible anywhere within a main program
  149. We can ________ pointer.

    1. increment
    2. decrement
    3. reassign
    4. all of the given
  150. if (a>b && a>c) then the condition will be true only if

    1. Both a>b and a>c are true
    2. a>b is false and a>c is true
    3. a>b is true and a>c is false
    4. Both a>b and a>c are false
  151. We can ________ references.

    1. increment
    2. decrement
    3. reassign
    4. None of the given
  152. The dynamic memory allocation uses ________ whereas static memory allocation uses ________.

    1. heap , stack
    2. stack , lists
    3. array , stack
    4. classes , array
  153. It is possible to return an object from function using this pointer.

    1. True
    2. False
  154. The remainder (%) operator is a ________ operator.

    1. Logical
    2. Arithmetic
    3. Relational
    4. Conditional
  155. 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
  156. If a function does not return anything, its return type will be ________.

    1. Return 0
    2. Null
    3. Zero
    4. Void
  157. 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);
  158. In statement a+b+c, at first

    1. a+b is executed first
    2. b+c is executed first
    3. All executed at the same time
    4. None of the given
  159. 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
  160. If B is designated as friend of A, B can access A's non-public members.

    1. B cannot access private member of A
    2. B cannot access protected member of A
    3. A can access non-public members of B
    4. A cannot access B
  161. We want to access array in random order which of the following approach is better?

    1. Pointer
    2. Array index
    3. Both pointers and array index are better
    4. Matrix
  162. ________ variables are those that are defined outside of main.

    1. Local
    2. Dynamic
    3. Global
    4. Static
  163. The default visibility for the data members of the class is

    1. private
    2. protected
    3. public
    4. accessible outside the class
  164. Which of the following is the correct syntax to access the value of first element of an array using pointer ptr?

    1. ptr[0]
    2. *(ptr+1)
    3. ptr[1]
    4. *ptr[0]
  165. 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
  166. ostream is a ________ operator.

    1. dependent
    2. member
    3. standalone
    4. None of the given
  167. 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
  168. 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;
    }

    1. banana
    2. banana
      any fruit
    3. banana
      mango
      any fruit
    4. None of the given
  169. In computer systems there are mainly ________ type of softwares.

    1. 1
    2. 2
    3. 3
    4. 4
  170. You cannot overload the ________ operator.

    1. ? :
    2. *
    3. /
    4. ++
  171. C is widely known as development language of ________ operating system.

    1. Windows
    2. Unix
    3. Mac OS
    4. Linux
  172. Both compiler and ________ are used to translate program into machine language code.

    1. debugger
    2. linker
    3. loader
    4. interpreter
  173. The constructor contains ________.

    1. return type
    2. no return type
    3. objects
    4. classes
  174. What will be the output of following statement?
    cout<<setfill('0')<<setw(7)<< 128;

    1. 0128128
    2. 0000128
    3. 1280000
    4. 0012800
  175. ________ 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
  176. The memory allocation in C++ is carried out with the help of ________.

    1. NULL pointer
    2. new operator
    3. dot operator
    4. + operator
  177. In C++, a variable can be declared anywhere in the program this will increase ________.

    1. writability
    2. readability
    3. portability
    4. efficiency
  178. ostream class is ________ and not under our control.

    1. user-defined
    2. built-in
    3. both user-defined and built-in
    4. None of the given
  179. Which of the following is the first step in FOR loop?

    1. Incrementing condition
    2. Termination condition
    3. Continuation condition
    4. Initialization condition
  180. What will be the size of the following character array?
    char name[] = "Adeel";

    1. 5
    2. 6
    3. 4
    4. 7
  181. We cannot increment ________.

    1. pointers
    2. arrays
    3. references
    4. variables
  182. The friend function of a class can have access ________.

    1. to the public data members only
    2. to the private data members
    3. to the protected data members
    4. to the main program
  183. 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
  184. The ________ statement allows us to select from multiple choices based on a set of fixed values for a given expression.

    1. switch
    2. break
    3. continue
    4. goto
  185. The parameter passed to isdigit() function is ________ variable.

    1. Character
    2. Boolean
    3. Integer
    4. Float
  186. 'While' loop may execute ________ or more times.

    1. three
    2. zero
    3. two
    4. one
  187. In C++, which of the following option has the cottect meaning of the expression a <= b"?

    1. a is greater than or equal to b
    2. a is less than b
    3. a is greater than b
    4. a is less than or equal to b
  188. Overloaded assignment operator must be

    1. Member function of class
    2. Non-member function of class
    3. Friend function of class
    4. Global function
  189. We cannot use ________ pointer for storing and reading data from it.

    1. 'NULL
    2. integer
    3. double
    4. zero
  190. There can be ________ 'default' statement(s) in any switch structure.

    1. 1
    2. 2
    3. 3
    4. n
  191. The increment of a pointer depends on its ________.

    1. variable
    2. value
    3. data type
    4. None of the given
  192. The malloc function takes ________ argument(s).

    1. two
    2. three
    3. four
    4. one
  193. A ________ is an array of characters that can store number of character specified.

    1. Char
    2. String
    3. Multidimensional array
    4. Data type
  194. The ________ structure is a multiple-selection construct which makes the code more efficient and easy to read and understand.

    1. multiple-if
    2. switch
    3. if-else
    4. else-if
  195. In programming, comments are used to explain the functioning of the ________.

    1. Debugger
    2. Editor
    3. Program
    4. Linker
  196. ________ are not available in C language.

    1. User defned functions
    2. Built in functions
    3. Library functions
    4. Inline functions
  197. 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
  198. < and > both are ________ operators.

    1. Arithmetic
    2. Relational
    3. Logical
    4. Mathematical
  199. 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
  200. The statement x += y can be interpreted as ________.

    1. Adding the value of the x to the value of the y and storing the result in x
    2. Adding the value of the y to the value of x, store the result in y
    3. Adding the value of the x to the value of x, store the result in x
    4. Adding the value of the y to the value of y, store the result in x
  201. 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
  202. To prevent dangling reference the functions returning reference should be used with ________.

    1. arrays
    2. global variables only
    3. local variables
    4. static and global variables
  203. In order to get the right most digit of a number, we divide this number by 10 and take ________.

    1. Its remainder
    2. Its quotient
    3. Its divisor
    4. The number
  204. C/C++ has many libraries which contain variables and function names normally starting with ________.

    1. Hyphen
    2. Hash
    3. Underscore
    4. emi-Colon
  205. The endl and flush are ________.

    1. Functions
    2. Operators
    3. Manipulators
    4. Objects
  206. C++ is a ________ language.

    1. High level
    2. Low level
    3. Machine
    4. Assembly language
  207. A function is a block of statements that can be defined once and used ________ in the program.

    1. One time
    2. Two times
    3. Three times
    4. As many times as user wants
  208. ________ is used as a dereferencing operator.

    1. *
    2. +
    3. -
    4. None of the above
  209. The memory allocation functions return a chunk of memory with a pointer of type ________.

    1. integer
    2. float
    3. ptr
    4. void
  210. Memory allocated from heap or free store ________.

    1. can be returned back to the system automatically
    2. can be allocated to classes only
    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
  211. 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;
    }

    1. 6,8,6
    2. 6,6,8
    3. 6,8,8
    4. 6,6,6
  212. What is the correct syntax to declare an array of size 10 of int data type?

    1. int [10] name;
    2. name[10] int;
    3. int name[10];
    4. int name[];
  213. A program statement that invokes a function is called ________.

    1. function declaration
    2. function call
    3. function definition
    4. function prototype
  214. Let suppose
    int a, b, c, d, e;
    a = b = c = d = e = 42;
    This can be interpreted by the compiler as

    1. (a = b = (c = (d = (e = 42))));
    2. a = (b = (c = (d = (e = 42))));
    3. a = b = (c = (d = (e = 42)));
    4. (a = b) = (c = d) = (e = 42);
  215. What will be the result of arithmetic expression 6+48/4*3?

    1. 10
    2. 40.5
    3. 42
    4. 41
  216. Which one of the following is mandatory preprocessor directive for c++?

    1. #undef
    2. #include
    3. #undef
    4. All of the given
  217. 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
  218. ________ will explain the function of a program.

    1. Comments
    2. Debugger
    3. Compiler
    4. Linker
  219. Structure is a collection of ________ under a single name.

    1. only functions
    2. only variables
    3. both functions and variables
    4. only data types
  220. A variable of character data type occupies ________ byte(s) in memory.

    1. 1
    2. 2
    3. 4
    4. 8
  221. How many nested loops would be required to manipulate n-dimensional array?

    1. n
    2. n + 1
    3. n - 1
    4. 2n
  222. Which of the following is an example of logical operator?

    1. &&,||
    2. <,>
    3. +,*
    4. /,%
  223. What will be the output of the following c++ code?
    #include<iostream.h>
    #define max 100
    main()
    {
    #ifdef max
    Cout<<"Hellow;
    }

    1. Hello
    2. "Hellow"
    3. Max is 100
    4. Error
  224. C++ views each file as a sequential stream of ________.

    1. Bits
    2. Bytes
    3. Numbers
    4. Words
  225. The default mode for writing into a file using ofstream object is ________.

    1. out
    2. bin
    3. app
    4. ate
  226. The ________ is called automatically when an object destroys.

    1. destructor
    2. constructor
    3. main program
    4. default constructor
  227. The main advantage of function overloading is ________.

    1. The program becomes portable
    2. The program becomes complex
    3. The function becomes inline
    4. The program becomes more readable
  228. Suppose int i = 10; then what is the output of cout<<oct<<i;

    1. 10
    2. 11
    3. 12
    4. 13
  229. 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*/
    }

    1. the logical operator && cannot be used in a test condition
    2. the while loop is an exit-condition loop
    3. the test condition is always false
    4. the test condition is always true
  230. What will be the output of following code?
    int x = 10;
    cout<<"x="<<x;

    1. 10
    2. "x=10"
    3. x=10
    4. 10=x
  231. 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);
  232. Constructor is itself a ________ of C++ and ________.

    1. class, can be overloaded
    2. function, cannot be overloaded
    3. function, can be overloaded
    4. object, can not be initialized
  233. The syntax of declaration of a function that returns the reference to an integer is ________.

    1. int & myfunc();
    2. int myfunc();
    3. int myfunc() &;
    4. integer & myfunc();
  234. ________ will be used for enclosing function statements into a block.

    1. " "
    2. ()
    3. []
    4. {}
  235. The name of the destructor is the same as that of a class proceeding with a ________.

    1. & sign
    2. # sign
    3. @ sign
    4. ~ sign
  236. 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
  237. A hierarchy of classes which are used to deal with console and disk files are called ________.

    1. Stream classes
    2. Simple classes
    3. Binary classes
    4. IO classes
  238. Member functions of the class ________ main program.

    1. are not accessible
    2. are accessible from
    3. are defined within the
    4. are private to
  239. Which of the following operators is used to access the value of variable pointed by a pointer?

    1. * operator
    2. -> operator
    3. && operator
    4. & operator
  240. 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);
  241. How many bytes of memory are occupied by array 'str'?

    char str[] = "programming";

    1. 10
    2. 11
    3. 12
    4. 13
  242. cout << i << " ";
    cout << d <<" ";
    cout << f;

    Above statements can be written within statement of one line as:

    1. cout << i <<" "<< d " "<< f << ;
    2. cout << i << << d << << f <<;
    3. cout << i <<" "<< d <<" "<< f;
    4. cout << i << " "<< d <<" " f<<;
  243. The function seekg() takes ________ parameter(s).

    1. 0
    2. 1
    3. 2
    4. 3
  244. 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
  245. Which of the following is true about the switch statement?

    1. It is valid for the large programs only.
    2. It is valid for the small programs only.
    3. It works efficiently on compound conditions which use logical operators.
    4. It cannot handle the compound conditions which use logical operators.
  246. When the logical operator AND (&&) combines two expressions exp1 and exp2 then the result will be true only ________.

    1. When both exp1 and exp2 are true
    2. When both exp1 and exp2 are false
    3. When exp1 is true and exp2 is false
    4. When exp1 is false and exp2 is true
  247. An address is a ________, while a pointer is a ________.

    1. constant, variable
    2. variable, constant
    3. global, variable
    4. non static variable, constant
  248. In C/C++, which of the following data type is used to store real numbers?

    1. float
    2. char
    3. boolean
    4. int
  249. ________ are very good tools for code reuse.

    1. operators
    2. loops
    3. functions
    4. variables
  250. ________ executes all the lines before error and stops at the line which contains the error.

    1. Intrepreter
    2. Compiler
    3. Linker
    4. Debugger
  251. What will be the output of the following code?

    int i = 0;

    while(i!=15){

    cout<<i<<" ";

    i = i + 5;

    }

    1. 1 5 10
    2. 5 10
    3. 0 5
    4. 0 5 10
  252. Whenever some number is added in an array name, it will jump as many ________ as the added number.

    1. rows
    2. value
    3. column
    4. bytes
  253. When the compiler overload the assignment (=) operator by default then

    1. Class members are not assigned properly
    2. Compiler does not allow default assignment operator
    3. Compiler does member wise assignment.
    4. None of the given
  254. NULL character is used to indicate the ________ of string.

    1. Start
    2. End
    3. Begin
    4. Middle
  255. The members of a class declared without any keyword are ________ by default.

    1. protected
    2. private
    3. public
    4. constant
  256. What is the highest legal index for the following array?
    int arr[4]

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