Skip to content

20 C++ Interview Questions asked in SRM Placements

    What is C++?

    As an extension of the C language, C++ was developed by Bjarne Stroustrup as a general-purpose cross-platform language which gives programmers a high level of control over system resources and memory.

     Why C++?

    The use of C++ is varied such as:

    – It is used in developing graphical user interface-based applications like adobe photoshop.

    – It is used in developing games as it overrides the complexity of 3D games.

    – There is much-animated software developed in C++

    – Most of the compilers are written in C++.

    – Google Chrome, Mozilla Firefox etc. web browsers are developed using C++

    There are many more such uses that make C++ the desired language.

     What is namespace in C++?

    If there are two or more functions with the same name defined in different libraries then how will the compiler know which one to refer to? Thus namespace came to the picture. A namespace defines the scope and differentiates functions, classes, variables etc. with the same name available in different libraries. The namespace starts with the keyword "namespace". The syntax for the same is as follows:






    namespace namespace_name {

       // code declarations


     What is operator overloading in C++?

    Operator overloading in C++ is an overloaded declaration is declaration in the same scope of function or operator declared with the same name more than once.

    How to learn C++?

    C++ is a programming language which is an extension of C. Thus, one should prefer to learn C first (it's not necessary). After learning C, then understand the basic difference between C and C++. Implement all the basic programs you learnt in C in C++ also. Then dive into the OOPs concept of C++. Do as much hands-on as possible to understand basic OOPs, and then dive into advanced-level OOPs. When all the basics are clear, build a small game to understand the structure and remain concepts if any. By following all these steps one can learn C++.

     What is the difference between C and C++?

    The difference between c and c++ is that C++ is an object-oriented language, which means that it has all the features of C as well as its own thing which is the concept of OOP. C++ has many functionalities of OOP that are missing from C such as encapsulation, abstraction, classes, objects, etc.



    C is a procedure-oriented programming language.

    C++ is an object-oriented programming language.

    C does not support data hiding.

    C++ supports data hiding.

    C is a subset of C++

    C++ is a superset of C.

    C doest not support Function and operator overloading

    C++ support Function and operator overloading

    Functions can not be defined inside structures.

    Functions can be defined inside structures.


     Login to see 30 more important Questions for SRM PLACEMENTS

    What is a template in C++?

    A template in C++ is used to pass data types as parameters. These make it easier and simpler to use classes and functions.

    template <typename T>

        int fun (T a,T b)


                            return (a+b);


                    int main(){



     What is using namespace std in C++?

    Using namespace std in C++ tells the compiler that you will be making use of the namespace called 'std'. The 'std' namespace contains all the features of the standard library. You need to put this statement at the start of all your C++ codes if you don't want to keep on writing std:: infront of every variable/string or whatever standard library feature you are making use of, as it becomes tedious to do so.

     How to download turbo C++ for windows 10?

    To download turbo c++ follow the steps mentioned below:

    Step-1: Download turbo C++ from http://www.turboccom/p/download.html

    Step-2: Extract the file.

    Step-3: Run setup.exe file.

    Step-4: Follow the instructions mentioned.

    How to paste in turbo C++?

    Paste in turbo C++ can be done by two techniques:

    • Shift+Insert
    • Open the file in notepad with .cpp extension. Make the changes and save it. After saving the file, you can open it from the Turbo C++ application file menu from where you stored the cpp file.



    What is a pointer in C++?

    Pointers in C++ are a data type that store the memory address of another variable.

    For eg.

    char *str = "Hi, How are you?";

                    Here the pointer variable *str points to the string "Hi, How are you?"


                    int age;

                    int *int_value;

                    *int_value = &age;

                    cout<<"Enter your age please:";


                    cout<<"\n Your age is:"<<*int_value;

                    // this will print your age as the variable is pointing to the variable age.

    What is a function in C++?

    A function in C++ is a block of code that can be referenced from anywhere in the system and that serves a specific purpose.

    int fun(){

                    int a = 11;

                    return 11;


            int main(){

                    int b = fun();


    What is a destructor in C++?

    Destructors in c++ are special functions/methods that are used to remove memory allocation for objects. They are called usually when the scope of an object ends. eg. when a function ends you can call it a destructor.


    They are of the same name as the class – syntax – ~<classname>();


    What is function overloading in C++?

    Function Overloading happens in C++ when two or more functions share the same name. They can be differentiated on the basis of the type of data they are passing as parameters or even the number of parameters they are passing. eg. int fun(char a); & int fun(int b); & void fun(int a, int b)

    What is stl in C++?

    Stl is the standard template library. It is a library that allows you to use a standard set of templates for things such as: Algorithms, functions, Iterators in place of actual code.

    queue<int> Q;





    How to run a C++ program in cmd?

    verify gcc installtion using the command:        

    $ gcc -vthen go to your working directory or folder where your code is:        

    $ cd <folder_name>then build the file containing your c code as such:        

    $ gcc main.cpp                


    $ g++ -o main main.cpp then run the executable generated in your system:        

    $ main.exe

    What is type casting in C++?

    Type casting in C is used to change the data type. They are of two types: Implicit Type Conversion: It is automatic. Explicit Type Conversion: It is user-defined.

    How to use a string in C++?

    A string is a sequence of characters. In C++, the string is a data type as well as a header file. This header file consists of powerful functions of string manipulation. A variable of string is declared as follows:

    string str= "Hello";

    And to use string one needs to include the header file.

    // Include the string library

    #include <string>

    // Create a string variable

    string str= "Hello";

    What is stream in C++?

    Stream refers to a stream of characters to be transferred between program thread and i/o.

    What is the difference between structure and class in C++?

    The difference between structure and class is as follows:

    – By default, the data members of the class are private whereas data members of structure are public.

    – While implementing inheritance, the access specifier for struct is public whereas for class its private.

    – Structures do not have data hiding features whereas class does.

    – Structures contain only data members whereas class contains data members as well as member functions.

    – In structure, data members are not initialized with a value whereas in class, data members can be initialised.

    – Structures are stored as stack in memory whereas class is stored as heap in memory.

    How to clear screen in C++?

    One can clear screen using – clrscr() or system("clear").

    Login to see 30 more important Questions for SRM PLACEMENTS 

    Leave a Reply