Top 100 Basic C++ interview questions and answers list

Top 100 Basic C++ interview questions and answers list

In this c++ interview questions course, we will be learning:
  • 75 c++ interview questions covering basic concepts for freshers
  • top 10 list of c++ interview questions related to competitive programming
  • c++ debugging questions

I have strategically designed these list and assure you this c++ interview questions will help you ace the upcoming interviews. Best of Luck...

Given below is the list of c++ interview questions and answers.Go through it and click on the questions link to read the answer[Link will be updated soon].


C++ interview Questions for freshers

  1. What are advantages of C++?
  2. Difference between C and C++
  3. Explain various OOPS concepts supported by C++?
  4. What is class and object in c++?
  5. Types of polymorphism in c++.
  6. What is namespace in c++?
  7. What are access specifiers in c++?
  8. new vs malloc()
  9. Explain use of friend function in c++ with examples?
  10. What is virtual function in c++?
  11. What is constructor in c++ with examples?
  12. What is default constructor in c++ with examples?
  13. What is destructor in c++ with example?
  14. What is operator overloading?
  15. What is function overloading?
  16. What is virtual inheritance?
  17. What is use of scope resolution operator in c++ with example?
  18. delete vs delete[] in c++
  19. What is pure virtual function?
  20. Difference struct vs class in c++
  21. What is class template in c++?
  22. What is virtual destructor in c++?
  23. Explain the use of volatile keyword in c++ with examples?
  24. What is abstract class in c++?
  25. What is reference variable in c++?
  26. What is use of static keyword on class member variables?
  27. What is static member function?
  28. Which access specifier helps in c++ data hiding?
  29. Explain delete operator with example.
  30. What is copy constructor in c++?
  31. Explain the concept of pointer in c++ with example.
  32. What is command line argument in c++?
  33. What is the use of extern storage specifier?
  34. What is header file and their importance in c++?
  35. Explain concept of recursion using c++.
  36. What is use of keyword ‘using’ in c++
  37. Difference == vs = in c++.
  38. Explain the static keyword in c++.
  39. Floating point operations in c++.
  40. What is type casting in c++?
  41. What is friend function?
  42. Explain function template.
  43. Explain class template
  44. What is encapsulation?
  45. What is compiler and linker?
  46. What is the difference between macro and inline?
  47. Define memory leak and how to avoid it?
  48. Explain pointers.
  49. Difference of base and derived class.
  50. What is preprocessor directive?
  51. Can a program be compiled without main() function?
  52. Advantages of using STL in c++.
  53. Define local and global scope of an variable.
  54. Difference of pre and post increment/decrement with examples.
  55. Define void return type in c++.
  56. What is inline function in c++?
  57. Explain storage classes in c++.
  58. DIfference of method overloading and method overriding in c++.
  59. Explain pure virtual functions in c++.
  60. Does c++ supports exception handling?
  61. goto statement in c++.
  62. Write code for dynamic allocation in c++.
  63. Char to int conversion in c++.
  64. Explain enum in c++.
  65. Define scope resolution operator in c++.

Comptetive Programming Questions

Problem-solving is a key aspect of any technical interview. Through this interviewer can understand how the person will tackle future real-world problems if the guy gets the job.

I have further furnished list of 12 questions, which are mainly asked in the interviews of various difficulty level basic. These questions are asked mainly in the companies like TCS, CTS, Capgemini, Wipro e.t.c although nowadays as the competition increases they also ask questions on the various topics of DS and Algo like Amazon, Microsoft, Google asked in there interviews.
These questions are equally important for computer science based Government jobs. In ISRO, BARC, NIELIT interviews, they check your depth in any subject which starts with very basics.
Let's start the list.
1. Fibonacci series up to N terms( with recursion and without)
For solving this question, first, you need to understand Fibonacci series and if you are solving this question with recursion, then the concept of recursion otherwise loops concept.
2. Number/ String palindrome or not
Concept of palindrome required as well as string concept and loops
3. Conversions
Binary to decimal, binary to octal, decimal to octal. 
And the vice-versa of the above ones. You need to have knowledge of all this as well as some extent concept of arrays.
4. Pattern Printing
Mostly pyramid and diamond patterns are asked. For this, you need the knowledge of loops as well as matrices.
5. GCD of two numbers
GCD concept is required as well as loops concept. The tricky part of this question is they can ask you to solve this question on O(nlogn) Time complexity. Then you need to use the concept of Euclidean algorithm
6. Prime Number
Concept of the prime number required here, like the above question if the time complexity is the matter then we need to use Sieve of Eratosthenes algorithm
7. Call by Reference
For solving any problem related to this, you need the concept of pointers.
8. Student Database
For making a student database, you need the concept of structure and unions.
9. Basic problem-solving questions on Array
Questions like remove a duplicate, second largest element in the array this type of questions can be asked. For solving this type of question Time Complexity is an important matter.
10. Problems on Mathematics:
Questions like sum of square numbers, e^x value, permutation and combinations. For solving this type of question basic mathematics skill and array with pointer concept required.
11. Problems on Matrices:
Questions can come on matrix multiplication, rotation and c++ code need to be written in an optimized way.  
12. STL related:
Standard Template Library is an important addition to C++. So interviewer can ask you to write a basic code snippet using STL or vector-related questions can be there.

C++ Debugging questions

1. Find the output of below program
void main()
 int x;

    case 1: cout<
    case 2: cout<
    case 3: cout<
    case 4: cout<

2. Output of below program is: 

int main()
int j;
unsigned char i=0x80;
return 0;


int main()
int i=10;
return 0;
Output of above program will be?
4. Output of the program is?
int main()
int x=20,y=35;
cout<<x<<" "<<y;
return 0;

5. Return value of fun(5) is?

int fun(int n)
int x=1,k;
if(n==1) return x;
return x;

6. Output of below c++ code?

using namespace std;

void nic(int *p)
int i=0;

int main()
int a[5]={6,5,3};
return 0;


int fun(int n)
if (n/10==0) 
    return (n%10);
   return fun(n%10+fun(n/10));

Return value of fun(9874) in above pseudo code?


8. Output of below program is?

a) 65472 65480    b) 65472 65490
c) 65472 65496    d) 65480 65496
int main()
/* Assume array begins at the address 65472 and size of int is 2 */
int k;
int a[3][4]
{ 1, 2, 3, 4
   5, 6, 7 ,8
    9, 10, 11, 12
cout<<a+1<<" "<<k;
return 0;

9. Output of below c++ code?

using namespace std;

void tih(int *x,int *y)
int t=*x;
int main()
int i=7,j=10;
cout<<i<<" "<<j;

10. Identify error in below program.

class Room
int w,h;
void Val(int w1,int h1)
void main()
Room obRoom;

11. Identify error in below program:

class TIH
int a,b;
TIH(int a1, int w=0):
void main()
TIH objT;
TIH objT(12,8);

12. Output of below pseudo code is?


initialize i,n
intialize and array of size n
  accept the values for the array
for o to n
  arr[i] = arr[i]+arr[i+1]
end for
print the array elements


Integer a

String str1

Set str1 = “goose”

a = stringLength(str1)

Print (a ^ 1)

Output of above pseudo code is?


cpp interview questions

Would you like to see your article here on tutorialsinhand. Join Write4Us program by

About the Author
Subhajit Guha Thakurta
Page Views :    Published Date : Jan 16,2021  
Please Share this page

Related Articles

Like every other website we use cookies. By using our site you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service. Learn more Got it!