C++ Quiz

  1. Which one is not a correct variable type in C++?
  2. float
  3. real
  4. int
  5. double
  6. Which operation is used as Logical ‘AND’ ?
  7. Operator-&
  8. Operator-||
  9. Operator-&&
  10. Operator +
  11. An expression A.B in C++ means ____
  12. A is member of object B
  13. B is member of Object A
  14. Product of A and B
  15. Wrong syntax
  16. A C++ code line ends with ___
  17. A Semicolon (;)
  18. A Fullstop(.)
  19. A Comma (,)
  20. A Slash (/)

5.         Declaration a pointer more than once may cause ____ :

A.    Error

B.    Abort

C.    Trap

D.    Null

6.         ______ function is used to allocate space for array in memory.

  1. malloc()
  2. realloc()
  3. alloc()
  4. calloc()

7.         A pointer pointing to a variable that is not initialized is called ____

  1. Void Pointer
  2. Null Pointer
  3. Empty Pointer
  4. Wild Pointer

8.         Default constructor has ____ arguments.

  1. No argument
  2. One Argument
  3. Two Argument
  4. None of these

9.         What is the scope of the variable declared in the user defined function?

A.    Whole program
B.    Only inside the {} block
C.    The main function
D.    No Scpoe

10.       Predict the output:

float x= 3.1496;

cout << setprecision(2) << x;

A.     3.14
B.     3.15
C.     3
D.    3.1

11.       How are many minimum numbers of functions need to be presented in c++?

A. 0
B. 1
C. 2
D. 3

12.       Unary scope resolution operator is denoted by

A.  ! !
B.  % %
C.  :
D.  : :

13.       What is the output of this program?

#include <iostream>

using namespace std;

void find()

void find()




int main()



    return 0;


A.  course
B.  coursecourse
C.  compile time error
D.  Run Time Error

14.       What will be the output of the following C++ code?

#include <iostream>

#include <string>

using namespace std;

int main(int argc, char const *argv[])


       const char *a = “Hello\0World”;


       return 0;


a)  Hello World
b)  Hello
c)  World
d)  Error

15.       What is a String in C Language.?

A)  String is a new Data Type in C

B)  String is an array of Characters with null character as the last element of array.

C)  String is an array of Characters with null character as the first element of array

D)  String is an array of Integers with 0 as the last element of array.

16.       Which of the following is not a comparison operator in C++ language?

a.    >                                      

b.    <=                        

c.     =                                     

d.    ==

17.       What is the output of below program?

int main()










return 0;


(A)  Hi
(B)  Bye
(C)  HiBye
(D)  Compilation Error

18.       What should be the output of below program?

int main()


    int a = 1;



    case 1: cout<<“One”;

    case 2: cout<<“Two”;

    case 3: cout<<“Three”;

    default: cout<<“Default”;


    return 0;


(A)   One
(B)    Compilation Error
(C)    Default
(D)    OneTwoThree

19.       What is size of void in bytes?

(A)  1
(B)  2
(C)  4
(D)  0

20.       Can any function call itself?

(A)  Yes
(B)  No
(C)  Compilation Error
(D)  Runtime Error

21.       What is the value of a in below program?

int main()


 int a, b=20;

 a = 90/b;

 return 0;


(A)  4.5
(B)  4.0
(C)  4
(D)  Compilation Error

22.       Which operator has highest precedence?

            (A)   ()

            (B)   =

            (C)   *

            (D)   ++

23.       What is output of below program?

int main()


  const int a=10;



  return 0;


(A)  10
(B)  11
(C)  Compilation Error
(D)  Linking Error

24.       What is currect syntax of for loop?

(A)  for(initialization; condition; increment/decrement)
(B)  for(increment/decrement; initialization; condition)
(C)  for(initialization, condition, increment/decrement)
(D)  for(condition; initialization; increment/decrement)

25.       A C++ code line ends with ___

(A)  A Semicolon (;)

(B)  A Fullstop(.)

(C)  A Comma (,)

(D)  A Slash (/)

26.       In CPP, members of a class are ______ by default.

A.  Public

B.  Private

C.  Protected

D.  Static

27.      Compiler generates ___ file

(A)   Executable code

(B)   Object code

(C)   Assembly code

(D) Library Code

28.       A visual representation of the sequence of steps to solve a problem I scalled_________:

(A)   Solution

(B)   Flowchart

(C)   Algorithm

(D)   Pseudo code

29.       What is the index number of the last element of an array with 9 elements?
a)  9
b)  8
c)  0
d)  Programmer-defined

30.      The operator used to access member function of a structure using its object.

(A)   .

(B)  ->

(C)   *

(D)   ?

31.     Which of the following is called address operator?
a)  *
b)  &
c)   _
d)  %

32.        Which of the following correctly declares an array?
a)  int array[10];
b)  int array;
c)  array{10};
d)  array array[10];

33.       What will be the output of the following C++ code?

    #include <stdio.h>


    using namespace std;

    int main ()


        int array[] = {0, 2, 4, 6, 7, 5, 3};

        int n, result = 0;

        for (n = 0; n < 8; n++)


                        result += array[n];


                cout << result;

                       return 0;


  1.  25
  2. 26
  3. 27
  4. 21

35.       What will be the output of the following C++ code?

           #include <stdio.h>
    #include <iostream>
    using namespace std;
    int main()
        int array[] = {10, 20, 30};
        cout << -2[array];
        return 0;
  1.  -15
  2.  -30
  3. compile time error
  4.  garbage value

36.       Which function is used to read a single character from the console in C++?
a)  cin.get(ch)
b)  getline(ch)
c)  read(ch)
d)  scanf(ch)

37.        Which of the following escape sequence represents tab?
a)  \t
b)  \r
c)  \b
d)  \a

38.       Who created C++?
a)  Bjarne Stroustrup
b)  Dennis Ritchie
c)  Ken Thompson
d)  Brian Kernighan

39.        What is the size of a boolean variable in C++?
a)  1 bit
b)  1 byte
c)  4 bytes
d)  2 bytes

  • What is the only function all C++ programs must contain?

A.  Start()

B.  System()

C.  main()

D.  Program()

  • Which of the following is not a correct variable type?

A.  Float

B.  Real

C.  Int

D.  Double

42.       By default how the value are passed in c++?
a)  call by value
b)  call by reference
c)  call by pointer
d)  call by object

43.       Which of the following is the correct operator to compare two variables?

A.   :=

B.   =

C.   Equal

D.   ==

44.       Which of the following is the boolean operator for logical-and?

A.  &

B.  &&

C.  |

D.  |&

45.       What will you use if you are not intended to get a return value?
a)  static
b)  const
c)  volatile
d)  void

46.       How many ways of passing a parameter are there in c++?
a)  1
b)  2
c)  3
d)  4

47.       The switch statement is also called as?
a) choosing structure
b) selective structure
c) certain structure
d) bitwise structure

48.        The if..else statement can be replaced by which operator?
a)  Bitwise operator
b)  Conditional operator
c)  Multiplicative operator
d)  Addition operator

49.       The destination statement for the goto label is identified by what label?
a)  $
b)  @
c)   *
d)   :

50.       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