C++ Interview Questions

1) Write a program in C++ to print “Hello World”?

2) Write a program in C++ to enter two integers and find their sum and average ?

3) Write a program in C++ to enter a string and find its length ?

4) Define basic type of variables used in C++?

There are four types of variables:

  • Bool: It is used to store boolean values (true or false).
  • Char: It is used to store character types.
  • int : It is used to store integer values.
  • float and double: Variables with large and floating point value.

5) What are the different types of Loops in C++ ?

There are three types of loops in C++:

  • For Loop.
  • While loop.
  • Do-while loop.

6) What are the types of storage classes in C++?

There are five types of storage classes in C++:

  • Automatic.
  • Register.
  • Static.
  • External.
  • Mutable.

7) What are the tokens in C++?

The smallest unit of a program is known as tokens.

It has the following tokens:

  • Identifiers.
  • Strings.
  • Keywords.
  • Operators.
  • Constants.

8) Does C++ has automatic garbage collection mechanism?

No,It doesn’t have automatic garbage collection.

9) Does constructor throws an exception?

No.

10) How “Late binding” is implemented in C++?

By using Virtual tables.

11) What is the use of continue statement in C++?

Example :

12) What is the use of break statement in C++?

Example:

13) Which inheritance type is used in the class given below?

Multiple inheritance type is used in the class.

14) Write a program in C++ to check the number is prime number or not?

Example of Prime Number:

15) What will be the output of the following code snippet?

Output:

Leave a Comment