Interview Questions

C and C++ Interview Questions and Answers

Interview Questions October 1, 2018
C and C Plus Plus Interview Questions

C and C++ Interview Questions & Answers

Here are the list of most frequently asked C and C++ Interview Questions & Answers in technical interviews. These questions and answers are suitable for both fresher’s and experienced professionals at any level. These C and C++ Interview Questions and Answers will guide you to clear all Interviews.

Best C and C++ Interview Questions and Answers

C and C++ Interview Questions and Answers for beginners and experts. List of frequently asked C and CPP Interview Questions with answers by Besant Technologies. We hope these interview questions and answers are useful and will help you to get the best job in industry. This C and C++ interview questions and answers are prepared by Professionals based on MNC Companies expectation. Stay tune we will update New C and C++ Interview questions with Answers Frequently.

Best C and C++ Interview Questions & Answers for Job Placements

Besant Technologies supports the students by providing C and C++ interview questions and answers for the job placements and job purposes. We provide the C and C++ online training also for all students around the world through the Gangboard medium. These are top interview questions and answers, prepared by our institute experienced trainers.
Here are the list of most frequently asked C and C++ Interview Questions and Answers in technical interviews. These questions and answers are suitable for both freshers and experienced professionals at any level.

Q1. What are the features in c programming?

C programming language supports multiple features. They are

  • 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.
  • Structured oriented programming Language: C program is structure oriented programming language means it will execute the statement in sequence
  • Modularity: In c programming language we can reduce the more line number of code by using modularity
  • Portability: C programming language is platform-independent means with minor modifications we can reuse the code on different platforms also.
  • Powerful Data Structure: With the help of data structures we can implement the complex application easily
Q2. What are the data types in c?

Data types divided into two types. They are

  • Predefined data types
  • 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

Q3. Types of errors in c?

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

  • Compile Time Errors
  • Run Time Errors
Q4. What are the Compile Time Errors ?

Here we can discuss about the compile time they are

  • Pre-processor errors: Pre-processor errors will occur at the time of pre-processing   EX: #include<stdi.h>
    Here “stdi.h” is the fatal error
  • Translate Errors: These errors also called as syntactical errors. EX: printf(“Hello\n”) //Here missing semicolon “;”
  • Linker Error: Linking errors occur while linking the modules , methods or functions Ex: print(“Hello\n”); //Here printf is the error
Q5. What are the Run time errors?

Here we can discuss the compile-time they are

  • Segmentation Fault: Un authorized memory access called as segmentation fault
  • Bus Error: Memory is not at all existing still programmer trying to access it
Q6. What is a function in c? Types of Functions?

The function is nothing but a collection of a set of statements called function. Functions are divided into two types they are

  •  Pre Defined Functions
  • User defined Functions
Q7. What are Pre Defined Functions?

The functions which are coming with compiler by default that functions we can call it as pre defined functions
Ex: sqrt,pow etc

Q8. What is User Defined Functions?

The functions which are written by the programmer, then we can call it as user defined functions. To write user defined function need three components. They are below

  • Function declaration
  • Function definition
  • Function call
Q9. Control Statements or Control Flow ?

Control statements are divided into three types. They are

  • Conditional Statements
  • Iterative Statements
  • Jump Statements
Q10. Conditional statements in c ?

These statements are decision making statements in source code. This are several types

  • if statements
  • if-else statement
  • if-else if –else statement
  • nested if statement
  • switch-case statement
Q11. Iterative ( loop) statements in c?

When we are going to use repeated code we will use iterative statements. These are several types

  • for loop
  • While loop
  • do-while loop
Q12. Jump statements in c ?

Jump statements are used to break the loops , continue the loop and jump to the required statement. These are several types

  • break
  • continue
  • goto
Q13. What is a header file?

It is also known as a library 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.

Q14. What are the translator in c?
  • assembler
  • compiler
  • interpreter.
Q15. What is assembler?

assembler is used to convert assembly lang.into machine lang. assembly lang. is noting but low level languge.

Q16. what is compiler?

It convert high level lang.into machine language.

Compiler takes the program as a whole and converts it into object code before execution.

Q17. what is variable?

variable is name given to mamory space that may  be used to store data.its value can be change depends on user reqirements.

Eg: int x=4 and int  x=8.

Q18. what are the different data types associated with variable ?
  • int-integer data type.
  • Char-character data type.
  • Float-floating point value.
  • Double-a double precision floting point value.
  • Void-valueless special purpose type.
Q19. what is variable declaration in c ?

In program first variable is declare and this variable is used in whole program .variable declaration tells compiler two things first name of variable and data type.

Q20. what are different types of variable?

a local variable, global variable, and static variable.

local variable

The variable that is defined within the body of a function or a block is known as a local variable. These variables are created when the function is entered and are destroyed when the function is exited.


void func(void)


int a,b;


Global variable

The global variable defines outside any function and is used for whole program.  These variable are automatically initialized to 0 at the time of declaration.

Static variable

static variable are declared by writing keyword static in front of the declaration.if static variable is not initialized then it is automatically initialized to 0.a static variable is initialized only one.

Static type var_name;

Q21. Can we declare variable anywhare in c ?

yes  due to modern gcc compiler support it.

Q22. How many keywords used in c?

32 Keywords are used in c (0-31)

Q23. What is register variable in c?

it is a case of automatic is used to store data.

Q24. What is extern in c ?

extern is a keyword which is used to extends the visibility of c variable and c function .and also due to extern variable memory is allocated for that variable.

Q25. What are the token in c program?

token is a smallest  basic component  of source code.tokens are ( constant,identifier ,operator,reserved word,separater)

Q26. Difference between declaration and definition?

The basic difference is that declaration has many form but the definition has only one. the declaration makes the variable as a part of a program  that can be used in the program. and definition tells the compiler to set storage for the variable.

Q27. Does c have a boolean variable type?

No,  is not a Boolean variable.

Q28. What is the basic component of the IEEE floating point?
  • sign
  • exponent
  • mantissa,
Q29. Why we use trigraph character?

when keywords are not supported some special character.

Q30. What is the keyword?

keyword hassome predefined meaning and it can not be changed.

Q31. What is constant?

constant have fixed values and they can not be changed during the execution of the program.

Q32. What is a function?

The function is a block of statement that perform some specific task, the function is the fundamental modular unit,it is reusable.

Q33. what are the different types of operator?
  • arithmetic operator.
  • logical operator.
  • relational operator.
  • comma  operator.
  • size of the operator.
  • conditional operator./ternary operator.
  • assignment operator.
  • bitwise operator.
  • increment and decrement operator.
  • other operator
Q34. when is the “void” keyword used in a function?

If function will not return any value at that time we use the void keyword at the leftmost part of the header function.

Q35. what is the significance of an algorithm to c programming?

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

Q36. What is the use of semicolon?

Due to semicolon compiler knows where each statement ends. and also it can divide the statement Into smaller statements for syntax acts as the delimiter.

Q37. the % symbol ha sa special use in a printf would place this character as a part of the output on the screen?

you can do it by using %% in the printf you can write printf(“10%%”)to have the op appear an s10%on the screen.

Q38. It is possible to create your own header file?

Yes, it is possible to create a customized header can be created by using #include directive followed by the name of your header file.

Q39. What is the difference between the text file and the header file?

Text file contains data can be easily understood by include number, letter and another character. on the other hand binary files contains 1s and 0s that computer can interpret.

Q40. What are the different types of errors?

1) Compile-time error_ a)Preprocessor error b) linker error c) syntax error.

2)Run time error_ a) segmentation error b) bus error

Q41. What is the run time error?

This error occurs when the program being 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.

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

Q43. What are the control structures?

control structure decides which instruction are to be performed in program.and also define how the control is transferred to another part of the program. i.e it controls the flow of the program.

  1. selection statement_ if …else, switch.
  2. Iterative statement_ while,do..while, for
  3. jump statement _ goto, break, continue.
Q44. when is a switch statement can be better than an if statement?

If we have more than one condition to check on a single variable or a single expression then switch is better than if. In a switch statements, program execution jumps to matching value. and if we use it if the condition it checks one by one condition.

Q45. Difference b/w entry controlled and exit controlled loop?

In entry controlled loop body is checked after checking the condition, ie condition is checked first and after that body will be executed. Eg. For loop, while loop.

In exit controlled loop body is executed first and then loop test condition is while loop.

Q46. Difference b/w sentinel control loop and counter control loop?

In counter control loop ,we know that exactly how many times loop body will be executed while in sentinel loop we don’t know about the loop recurrence,execution of loop is based on condition not on counter.

Q47. What is fall down property?

switch case statements follows fall down property. It means when case block is executed and break statements is not used after the block statements,then it will execute next case or default statements until break not reached or switch not finished.

Q48. What are the jumping statements in c lang.and how these work?

It is used to transfer the program control from one location to other location .

1.goto_ is used to jump program control from one locationto de

fine label

2.break_ is used in switch and loop statements it is used to break the execution of the switch and transfer the control after switch statement.

3continue_ is used in looping statement it transfer programs control in the starting of the loops body.

4.return_generally return is used in function body it transfer programs control from called to calling function.

Q49. Can we used continue statement without using loop?

No,continue statement can be used within the loop only.if we used without loop there will be compiler error “misplaced continue”.

Q50. can goto statements transfer program control from one function to another function?

No,it can transfer programs control within the function only.

Q51. what do you mean by array?

Array is a collection of same data type elements.Arrays are  always fixed.

Q52. How to creat array?

array contain data type ,array name and size of array

It can be delare as eg. int arr[5];  or int arr[];

Q53. Can we change the array size at run time?

No,we can not change the array size.

Q54. What is the default value of array?

default values of array is as follow

1.For byte ,short ,long ,int  default value id 0.

2For float ,double default values is 0.0.

3.For boolen default value is false.

4.For object default value is null.

Q55. When you pass array to an function what actually pass?

when you pass an array as a function the base address of an array will be passed.

Q56. what is the return 0 statement in main function indicate?

The return 0 value in the main function considered as the exit status of program or application. In some program return 0 is a success status of the program.

Q57. Can you return an array in c?

In c program, we cannot return the whole array as an argument to a function. but you can return a pointer to an array by specifying an array name without an index.

Q58. How does an array work?

array is a collection of similar data type elements. the length of array is established when the array is created .each atom is called elements of array,and each elements is accessed by its numerical index.

Q59. What is array indexing

The array is a data structure consisting of a collection of elements each is identified by array index or key.

Q60. How arrays are different from a normal variables

the array holds multiple values, whereas the normal variable holds a single value

Q61. What is dimensional array?

One dimensional array is a type of linear array.accessing its elements involves a single subscript which can be row or column index.

Besant Technologies – Chennai & Bangalore Branch Locations

Besant Technologies - Velachery Branch

Plot No. 119, No.8, 11th Main road, Vijaya nagar,

Velachery, Chennai - 600 042

Tamil Nadu, India

Landmark - Reliance Digital Opposite Street

  +91-8099 770 770

Besant Technologies - Tambaram Branch

No.2A, 1st Floor, Duraisami Reddy Street,

West Tambaram, Chennai - 600 045

Tamil Nadu, India

Landmark - Near By Passport Seva

  +91-8099 770 770

Besant Technologies - OMR Branch

No. 5/318, 2nd Floor, Sri Sowdeswari Nagar,

OMR, Okkiyam Thoraipakkam, Chennai - 600 097

Tamil Nadu, India

Landmark - Behind Okkiyampet Bus Stop,

  +91-8099 770 770

Besant Technologies - Porur Branch

No. 180/84, 1st Floor, Karnataka Bank Building,

Trunk Road, Porur, Chennai - 600 116

Tamil Nadu, India

Landmark - Opposite to Gopalakrishna Theatre

  +91-8099 770 770

Besant Technologies - Anna Nagar Branch

Plot No:1371, 28th street kambar colony,

I Block, Anna Nagar, Chennai - 600 040

Tamil Nadu, India

Landmark - Behind Reliance Fresh

  +91-8099 770 770

Besant Technologies - T.Nagar Branch

Old No:146/2- New No: 48,

Habibullah Road,T.Nagar, Chennai - 600 017

Tamil Nadu, India

Landmark - Opposite to SGS Sabha

  +91-8099 770 770

Besant Technologies - Thiruvanmiyur Branch

22/67, 1st Floor, North mada street, Kamaraj Nagar

Thiruvanmiyur, Chennai 600041

Tamil Nadu, India

Landmark - Above Thiruvanmiyur ICICI Bank

  +91-8099 770 770

Besant Technologies - Siruseri Branch

No. 4/76, Ambedkar Street, OMR Road, Egatoor, Navallur,

Siruseri, Chennai 600130

Tamil Nadu, India

Landmark - Near Navallur Toll Gate, Next to Yamaha Showroom

  +91-8099 770 770

Besant Technologies - Maraimalai Nagar Branch

No.37, Ground Floor, Thiruvalluvar Salai,

Maraimalai Nagar,Chennai 603209

Tamil Nadu, India

Landmark - Near to Maraimalai Nagar Arch

  +91-8099 770 770

Besant Technologies - BTM Layout Branch

No 2, Ground floor, 29th Main Road,

Kuvempu Nagar,BTM Layout 2nd Coming from Silkboard,

AXA company signal, Stage, Bangalore - 560 076

Karnataka, India

Landmark - Next to OI Play School

  +91-8767 260 270

Besant Technologies - Marathahalli Branch

No. 43/2, 2nd Floor, VMR Arcade,

Varthur Main Road, Silver Springs Layout,

Munnekollal, Marathahalli, Bengaluru - 560037

Karnataka, India

Landmark - Near Kundalahalli Gate Signal

  +91-8767 260 270

Besant Technologies - Rajaji Nagar Branch

No. 309/43, JRS Ecstasy, First Floor,

59th Cross, 3rd Block, Bashyam Circle,

Rajaji Nagar, Bangalore - 560 010

Karnataka, India

Landmark - Near Bashyam Circle

  +91-8767 260 270

Besant Technologies - Jaya Nagar Branch

No. 2nd Floor,1575,11th Main Road,

4th T-Block, Pattabhirama Nagar,

Jaya Nagar, Bangalore - 560 041

Karnataka, India

Landmark - Opposite to Shanthi Nursing Home

  +91-8767 260 270

Besant Technologies - Kalyan Nagar Branch

No.513, 4th Cross Rd

2nd Block, HRBR Layout,

Kalyan Nagar, Bangalore - 560 043

Karnataka, India

Landmark - Opposite to kalayan nagar Axis Bank

  +91-8767 260 270

Besant Technologies - Electronic City Branch

No. 7, 3rd Floor, Ganga Enclave,

Neeladri Road, Karuna Nagar, Doddathoguru Village,

Electronics City Phase 1, Electronic City,

Bangalore - 560100, karnataka, India

Landmark - Adjacent to HDFC Bank and State Bank Of India

  +91-8767 260 270

Besant Technologies - Indira Nagar Branch

No.54, 1st Floor,

5th Main kodihalli,

Bengaluru, Karnataka 560008, India

Landmark - Behind Leela Palace Hotel,

  +91-8767 260 270

Besant Technologies - HSR Layout Branch

Plot No. 2799 & 2800, 27th Main,

1st Sector, HSR Layout,

Bengaluru, Karnataka 560102, India

  +91-8767 260 270

Besant Technologies - Hebbal Branch

No.29, 2nd Floor, SN Complex,

14th Main Road, E-Block Extention, Sahakara Nagar,

Bengaluru, Karnataka -560092, India

  +91-8767 260 270

Scroll Up