C/C interview question set 1/C/C Interview Questions and Answers for Freshers & Experienced

Which is the best C++ compiler?

There are several good compilers for C++ such as:
– MinGW / GCC
– Borland c++
– Dev C++
– Embracadero
– Clang
– Visual C++
– Intel C++
– Code Block

GCC and clang are great compilers if the programmer’s target more portability with good speed.
Intel and other compilers target speed with relatively less emphasis on portability.

Posted Date:- 2021-08-24 05:34:04

What is enum in C++?

enum is abbreviation of Enumeration which assigns names to integer constant to make a program easy to read. Syntax for the same:

enum enum_name{const1, const2, ……. };

Posted Date:- 2021-08-24 05:32:02

How to exit from turbo C++?

To exit Turbo C++, use the Quit option under the File Menu, or press Alt + X.

Posted Date:- 2021-08-24 05:31:12

What is conio.h in C++?

Conio.h is a header file used for console input and output operations and is used for creating text based user interfaces.

Posted Date:- 2021-08-24 05:29:53

What is exception in C++ ?

Runtime abnormal conditions that occur in the program are called exceptions. These are of 2 types:
– Synchronous
– Asynchronous

C++ has 3 specific keywords for handling these exceptions:
– try
– catch
– throw

Posted Date:- 2021-08-24 05:29:05

What is bool in C++?

Bool is a data type in C++ which takes two values- True and False. Syntax is as follows:
bool b1 = true;

A sample code is as follows:

using namespace std;
int main()
int a= 60, b= 70;
bool c, d;
c= a== b; // false

c= a< b; // true

cout <<b1;
cout << b2 ;

return 0;

Posted Date:- 2021-08-24 05:26:27

Which operator cannot be overloaded in C++ ?

Some of the operators that cannot be overloaded are as follows:

– Dot operator- “.”
– Scope resolution operator- “::”
– “sizeof” operator
– Pointer to member operator- “.*”

Posted Date:- 2021-08-24 05:24:21

What differences separate structure from a class in C++?

There are two important distinctions between a class and a structure in C++. These are:

1. When deriving a structure from a class or some other structure, the default access specifier for the base class or structure is public. On the contrary, default access specifier is private when deriving a class.
2. While the members of a structure are public by default, the members of a class are private by default

Posted Date:- 2021-08-24 05:23:22

Can we provide one default constructor for our class?

No, we cannot provide one default constructor for our class. When a variable in the class type is set to null, it means that it was never initialized and the outcomes will be zero.

Posted Date:- 2021-08-24 05:21:41

What Is Meant By Const_cast?

The const_cast is used to convert a const to a non-const. This is shown in the following program:

void main( )
const int a = 0 ;
int *ptr = ( int * ) &a ; //one way
ptr = const_cast_ ( &a ) ; //better way

Here, the address of the const variable a is assigned to the pointer to a non-const variable. The const_cast is also used when we want to change the data members of a class inside the const member functions. The following code snippet shows this:

class sample
int data;
void func( ) const
(const_cast (this))->data = 70 ;

Posted Date:- 2021-08-24 05:20:51

What is the default constructor?

The compiler provides a constructor to every class in case the provider does not offer the same. This is when the programmer provides the constructor with no specific parameters than it is called a default constructor. The code for default constructor can be displayed in the following example.

// Cpp program to illustrate the
// concept of Constructors
#include <iostream>
using namespace std;
class construct {
int a, b;
// Default Constructor
a = 10;
b = 20;
int main()
// Default constructor called automatically
// when the object is created
construct c;
cout << "a: " << c.a << endl
<< "b: " << c.b;
return 1;

Posted Date:- 2021-08-24 05:18:12

Is it possible for a C++ program to be compiled without the main() function?

Yes, it is possible. However, as the main() function is essential for the execution of the program, the program will stop after compiling and will not execute.

Posted Date:- 2021-08-24 05:17:15

What Is A Unnitialised Pointer?

When we create a pointer the memory to the pointer is allocated but the contents or value that memory has to hold remains untouched. Unitialised pointers are those pointers which do not hold any initial value.

Posted Date:- 2021-08-24 05:16:24

What Is The Disadvantage Of Using A Macro?

The major disadvantage associated with the macro is :

When a macro is invoked no type checking is performed.Therefore it is important to declare a macro coreectly so that it gives a correct answer whenever it is called inside the program.

Posted Date:- 2021-08-24 05:15:46

What Do You Mean By Global Variables?

These are the variables which remains visible throughout the program and are not recreated when they are recalled.

These types are by default initialised to zero and allocated memory on Data Segment.View answers in details

Posted Date:- 2021-08-24 05:14:32

Can Union Be Self Referenced?

No, Union cannot be self referenced because it shares a single memory for all of its data members.View answers in details

Posted Date:- 2021-08-24 05:13:33

What are logical error and how does it differ from syntax error?

logical error occurs at compile time. this happen when a wrong formula was inserted into the code wrong sequence of command was performed.on the other hand syntax error occurs due to incorrect command that is not recognized by the compiler.

Posted Date:- 2021-08-24 05:12:45

What is the run time error?

This error occurs when the program being executed.one common instance wherein run time error can happen is when you are trying to divide a number by zero.when run time error occurs program execution will pause, showing which program line caused the error.

Posted Date:- 2021-08-24 05:12:11

How to run C++ program in cmd?

verify gcc installtion using the command:
$ gcc -v

then 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

Posted Date:- 2021-08-24 05:11:29

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;


Posted Date:- 2021-08-24 05:10:49

Who invented C++?

C++ invented by Bjarne Stroustrup in 1985.

Posted Date:- 2021-08-24 04:59:24

Keyword Mean In Declaration?

This keyword indicated that the function or the variable is implemented externally and it emphasizes that the variable ot the function exits external to the file or function.

We use this keyword when we want to make anything global in the project, it does not lie within any function.

Posted Date:- 2021-08-24 04:58:03

Explain the significance of vTable and vptr in C++ and how the compiler deals with them

vTable is a table containing function pointers. Every class has a vTable. vptr is a pointer to vTable. Each object has a vptr. In order to maintain and use vptr and vTable, the C++ compiler adds additional code at two places:

1. In every constructor – This code sets vptr:
1.Of the object being created
2.To point to vTable of the class
2. Code with the polymorphic functional call – At every location where a polymorphic call is made, the compiler inserts code in order to first look for vptr using the base class pointer or reference. The vTable of a derived class can be accessed once the vptr is successfully fetched. Address of derived class function show() is accessed and called using the vTable.

Posted Date:- 2021-08-24 04:57:09

Can we declare variable anywhare in c ?

yes due to modern gcc compiler support it.

Posted Date:- 2021-08-24 04:54:57

How C Functions Prevents Rework And Therefore Saves The Programmers Time As Well As Length Of The Code ?

As we know that c allows us to make functions and cal them where ever needed, it prevents rework by calling the same function again and again where ever requires intead for example if we make a funtion that adds two numbers, it can be called anywhere in the program where ever the addintion is needed and we do not need to code again for adding any number.

It also shortens the length of the program as we do not need to code again the same thing for next time we can simple call the funtion and use it whenever needed.

Posted Date:- 2021-08-24 04:54:04

What is a header file?

It is also known as a library file.it contains definition and prototype of the program. header file contains a set of functions.

Eg.stdio.h it contains a definition and prototype of commands like scanf and printf.

Posted Date:- 2021-08-24 04:53:09

Control Statements or Control Flow ?

Control statements are divided into three types. They are

1. Conditional Statements
2. Iterative Statements
3. Jump Statements

Posted Date:- 2021-08-24 04:52:32

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.turboc8.com/p/download.html
Step-2: Extract Turbo.C.3.2.zip file.
Step-3: Run setup.exe file.
Step-4: Follow the instructions mentioned.

Posted Date:- 2021-08-24 04:51:03

What are the Run time errors?

Here we can discuss the compile-time they are

a) Segmentation Fault: Un authorized memory access called as segmentation fault
b) Bus Error: Memory is not at all existing still programmer trying to access it

Posted Date:- 2021-08-24 04:50:11

What is template in C++?

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

template <typename T>

int fun (T a,T b)
return (a+b);

int main(){

Posted Date:- 2021-08-24 04:49:27

What is operator overloading in C++?

An overloaded declaration is a declaration in the same scope of function or operator declared with the same name more than once.

Posted Date:- 2021-08-24 04:48:25

Can we use a continue statement without using a loop?

No, continue statement can be used within the loop only.

Posted Date:- 2021-08-24 04:32:34

What is the difference between the text file and a binary file?

Text file includes letters, numbers, and other characters. It is easily understood by humans. Binary files contain zeros and ones that only computers can understand and interpret.

Posted Date:- 2021-08-24 04:32:06

What is the importance of an algorithm in C programming?

Algorithm provides step by step procedure on how a solution can be derived.

Posted Date:- 2021-08-24 04:31:44

What is Variable?

Variable is the name given to the memory space that may be used to store data. Its value can be changed depending on user requirements.

Posted Date:- 2021-08-24 04:31:21

Can we have a recursive inline function in C++?

Even though it is possible to call an inline function from within itself in C++, the compiler may not generate the inline code. This is so because the compiler won’t determine the depth of the recursion at the compile time.

Nonetheless, a compiler with a good optimizer is able to inline recursive calls until some depth is fixed at compile-time and insert non-recursive calls at compile time for the cases when the actual depth exceeds run time.

Posted Date:- 2021-08-24 04:30:47

What is the function of the keyword “Volatile”?

"Volatile" is a function that helps in declaring that the particular variable is volatile and thereby directs the compiler to change the variable externally- this way, the compiler optimization on the variable reference can be avoided.

Posted Date:- 2021-08-24 04:30:11

Briefly explain the concept of Inheritance in C++.

C++ allows classes to inherit some of the commonly used state and behavior from other classes. This process is known as inheritance.

Posted Date:- 2021-08-24 04:29:40

Define Encapsulation in C++?

Encapsulation is the process of binding together the data and functions in a class. It is applied to prevent direct access to the data for security reasons. The functions of a class are applied for this purpose. For example, the customers' net banking facility allows only the authorized person with the required login id and password to get access. That is too only for his/her part of the information in the bank data source.

Posted Date:- 2021-08-24 04:29:09

Define Object in C++?

Object is an instance of the class. An object can have fields, methods, constructors, and related. For example, a bike in real life is an object, but it has various features such as brakes, color, size, design, and others, which are instances of its class.

Posted Date:- 2021-08-24 04:28:36

Can we call C++ OOPS? and Why?

Yes, C++ can be called OOPS. The full form of OOPS is an Object-Oriented Programming System, which means a paradigm that provides an application of various concepts, including data binding, polymorphism, inheritance, and various others.

Posted Date:- 2021-08-24 04:28:00

What is a Compiler?

It converts high-level language to machine language.

Posted Date:- 2021-08-24 04:27:29

What are the User-defined Functions?

The functions which are written by the programmer are called User-defined Functions. You will need three components to write user-definedfunctions. They are Function declaration, Function definition, and Function call.

Posted Date:- 2021-08-24 04:26:55

What are the Pre-defined Functions?

The functions which are coming with the compiler by default are known as Pre-defined Functions. E.g.:- sqrt, pow.

Posted Date:- 2021-08-24 04:26:01

What are the differences between references and pointers?

Both references and pointers can be used to change local variables of one function inside another function. Both of them can also be used to save copying of big objects when passed as arguments to functions or returned from functions, to get efficiency gain.
Despite above similarities, there are following differences between references and pointers.

References are less powerful than pointers
1) Once a reference is created, it cannot be later made to reference another object; it cannot be reseated. This is often done with pointers.
2) References cannot be NULL. Pointers are often made NULL to indicate that they are not pointing to any valid thing.
3) A reference must be initialized when declared. There is no such restriction with pointers

Due to the above limitations, references in C++ cannot be used for implementing data structures like Linked List, Tree, etc. In Java, references don’t have above restrictions, and can be used to implement all data structures. References being more powerful in Java, is the main reason Java doesn’t need pointers.
References are safer and easier to use:
1) Safer: Since references must be initialized, wild references like wild pointers are unlikely to exist. It is still possible to have references that don’t refer to a valid location (See questions 5 and 6 in the below exercise )
2) Easier to use: References don’t need dereferencing operator to access the value. They can be used like normal variables. ‘&’ operator is needed only at the time of declaration. Also, members of an object reference can be accessed with dot operator (‘.’), unlike pointers where arrow operator (->) is needed to access members.

Posted Date:- 2021-08-24 04:25:18

What are the differences between C and C++?

1) C++ is a kind of superset of C, most of C programs except few exceptions (See this and this) work in C++ as well.
2) C is a procedural programming language, but C++ supports both procedural and Object Oriented programming.
3) Since C++ supports object oriented programming, it supports features like function overloading, templates, inheritance, virtual functions, friend functions. These features are absent in C.
4) C++ supports exception handling at language level, in C exception handling is done in traditional if-else style.
5) C++ supports references, C doesn’t.
6) In C, scanf() and printf() are mainly used input/output. C++ mainly uses streams to perform input and output operations. cin is standard input stream and cout is standard output stream.

Posted Date:- 2021-08-24 04:24:01

What Are Structures And Unions?

While handling real world problems we come across situations when we want to use different data type as one, C allows the user to define it own data type known as structures and unions.Structures and unions gathers together different atoms of informations that comprise a given entity.

Posted Date:- 2021-08-24 04:23:00

Types of errors in c?
Errors in c programming are divid

Errors in c programming are divided in two types. They are

a) Compile Time Errors
b) Run Time Errors

Posted Date:- 2021-08-24 04:22:19

What are the data types in c?

Data types divided into two types. They are

a). Predefined data types
b). User defined data types
Predefined Data types: Int, char, float and double are the predefined data types
User-defined data types: Arrays, Pointers, strings, and structures are user-defined data types

Posted Date:- 2021-08-24 04:21:36

What are the features in c programming?

C programming language supports multiple features. They are

1. Middle-Level Programming Language: C programming supports high-level features like Pointers, Structures data structures and as well as it will supports assembly code also so we conclude c as a middle level programming language.
2. Structured oriented programming Language: C program is structure oriented programming language means it will execute the statement in sequence
3. Modularity: In c programming language we can reduce the more line number of code by using modularity
4. Portability: C programming language is platform-independent means with minor modifications we can reuse the code on different platforms also.
5. Powerful Data Structure: With the help of data structures we can implement the complex application easily.

Posted Date:- 2021-08-24 04:19:48

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.

Posted Date:- 2021-08-24 04:18:11

R4R Team
R4R provides C/C Freshers questions and answers (C/C Interview Questions and Answers) .The questions on R4R.in website is done by expert team! Mock Tests and Practice Papers for prepare yourself.. Mock Tests, Practice Papers,C/C interview question set 1,C/C Freshers & Experienced Interview Questions and Answers,C/C Objetive choice questions and answers,C/C Multiple choice questions and answers,C/C objective, C/C questions , C/C answers,C/C MCQs questions and answers R4r provides Python,General knowledge(GK),Computer,PHP,SQL,Java,JSP,Android,CSS,Hibernate,Servlets,Spring etc Interview tips for Freshers and Experienced for C/C fresher interview questions ,C/C Experienced interview questions,C/C fresher interview questions and answers ,C/C Experienced interview questions and answers,tricky C/C queries for interview pdf,complex C/C for practice with answers,C/C for practice with answers You can search job and get offer latters by studing r4r.in .learn in easy ways .