Frequently Asked Interview Questions And Answers For C and C++ Programming Freshers

50,000+ Students Trained, 19+ Our Offices, 18+ Courses Offered,

Job Guarantee + Job Satisfaction, 2000+ Company Tie Ups For Placements

C and C++ Interview Question

Most Important Question:-

  1. 1. What are the key features in C programming language?
  • Portability – Platform independent language.
  • Modularity – Possibility to break down large programs into small modules.
  • Flexibility – The possibility to a programmer to control the language.
  • Speed – C comes with support for system programming and hence it is compiling and executes with high speed when comparing with other high-level languages.
  • Extensibility – Possibility to add new features by the programmer.
  1. 2. What are the basic data types associated with C?
  • Int – Represent number (integer)
  • Float – Number with a fraction part.
  • Double – Double-precision floating point value
  • Char – Single character
  • Void – Special purpose type without any value.
  1. 3. What is the description for syntax errors?
Ans.  The mistakes when creating a program called syntax errors. Misspelled commands or incorrect case commands, an incorrect number of parameters when called a method /function, data type mismatches can identify as common examples for syntax errors.  
  1. 4. What is the process to create increment and decrement stamen in C?
Ans : are two possible methods to perform this task.
  1. 1) Use increment (++) and decrement (-) operator.
  2. Example When x=4, x++ returns 5 and x- returns 3.
  3. 2) Use conventional + or – sign.
When x=4, use x+1 to get 5 and x-1 to get 3.  
  1. 5. What are reserved words with a programming language?
Ans: The words that are part of the slandered C language library are called reserved words. Those reserved words have special meaning and it is not possible to use them for any activity other than its intended functionality.   Example void, return, int.  
  1. 6. What is the explanation for the dangling pointer in C?
Ans.  When there is a pointer with pointing to a memory address of any variable, but after some time the variable was deleted from the memory location while keeping the pointer pointing to that location.  
  1. 7. Describe static function with its usage?
Ans.  A function, which has a function definition prefixed with a static keyword is defined as a static function. The static function should call within the same source code.  
  1. 8. What is the difference between abs() and fabs() functions?
Ans.  Both functions are to retrieve absolute value. abs() is for integer values and fabs() is for floating type numbers. Prototype for abs() is under the library file and fabs() is under .  
  1. 9. Describe Wild Pointers in C?
Ans.  uninitialized pointers in the C code are known as Wild Pointers. These are a point to some arbitrary memory location and can cause bad program behavior or program crash.  
  1. 10. What is the difference between ++a and a++?
Ans.  ‘++a” is called prefixed increment and the increment will happen first on a variable. ‘a++’ is called postfix increment and the increment happens after the value of a variable used for the operations.  
  1. 11. Describe the difference between = and == symbols in C programming?
Ans.  ‘==’ is the comparison operator which is use to compare the value or expression on the left-hand side with the value or expression on the right-hand side. ‘=’ is the assignment operator which is use to assign the value of the right-hand side to the variable on the left-hand side.  
  1. 12. What is the explanation for prototype function in C?
Ans.  Prototype function is a declaration of a function with the following information to the compiler.
  • • Name of the function.
  • • The return type of the function.
  • • Parameters list of the function.
int sum(int, int); In this example Name of the function is Sum, the return type is integer data type and it accepts two integer parameters.  
  1. 13. What is the explanation for cyclic nature of data types in C?
Ans.  Some of the data types in C have special characteristic nature when a developer assign value beyond the range of the data type. There will be no any compiler error and the value change according to a cyclic order. This is called as cyclic nature and Char, int, long int data types have this property. Further float, double and long double data types do not have this property.   This is called as cyclic nature and Char, int, long int data types have this property. Further float, double and long double data types do not have this property.  
  1. 14. Describe the header file and its usage in C programming?
Ans.  The file contains the definitions and prototypes of the functions being used in the program are called a header file. It is also known as a library file.   Example – The header file contains commands like printf and scanf is the stdio.h.  
  1. 15. There is a practice in coding to keep some code blocks in comment symbols than delete it when debugging. How this affect when debugging?
Ans.  This concept called as commenting out and is the way to isolate some part of the code which scans possible reason for the error. Also, this concept helps to save time because if the code is not the reason for the issue it can simply uncomment.  
  1. 16. What are the general description for loop statement and available loop types in C?
Ans.  A statement that allows executing statement or group of statements in repeated way is defined as a loop. Following diagram explains   Following diagram explains a general form of a loop.           There are 4 types of a loop statement in C.
  • • While loop
  • • For Loop
  • • Do…While Loop
  • • Nested Loop
  1. 17. What is a nested loop?
Ans.  A loop running within another loop is referred as a nested loop. The first loop is called Outer loop and inside the loop is called Inner loop. Inner loop executes the number of times define an outer loop.  
  1. 18. What is the general form of function in C?
Ans. Function definition in C contains four main sections.    return_type function_name( parameter list ) { body the function }
  • • Return Type – Data type of the return value of the function.
  • • Function Name – The name of the function and it is important to have a meaningful name that describes the activity of the function.
  • • Parameters – The input values for the function that need to use perform the required action.
  • • Function Body – Collection of statement that needs to perform the required action.
  1. 19. What is a pointer on a pointer in C programming language?
Ans.  A pointer variable that contains the address of another pointer variable is called pointer on a pointer. This concept de-refers twice to point to the data held by a pointer variable.   int a = 5, *x = &a, **y=&x;   In this example **y returns value of the variable a.  
  1. 20. What are the valid places to have keyword “Break”?
Ans.  The purpose of the Break keyword is to bring the control out of the code block which is executing. It can appear only in Looping or switch statements.  
  1. 21. What is the behavioral difference when include header file in double quotes (“”) and angular braces (<>)?
Ans.  When Header file include within double quotes (“”), compiler search first in the working directory for the particular header file. If not found then in the built in the include path. But when Header file include within angular braces (<>), the compiler only search in the working directory for the particular header file.  
  1. 22. What is a sequential access file?
Ans.  In general programs store data into files and retrieve existing data from files. With the sequential access file such data saved in a sequential pattern. When retrieving data from such files each data need to read one by one until required information find.  
  1. 23. What is the method to save data in stack data structure type?
Ans.  Data is stored in Stack data structure type using First in Last out (FILO) mechanism. Only top of the stack is accessible at a given instance. Storing mechanism is referred as a PUSH and retrieve is referred as a POP.  
  1. 24. What is the significance of C program algorithms?
Ans.  The algorithm needs to create first and it contains step by step guidelines on how the solution should create. Also, it contains the steps to consider and the required calculations/operations within the program.  
  1. 25. What is the correct code to have following output in C using nested for loop?
    int main () {
    int a;
    int b;
    /* for loop execution */
    for (a = 1; a < 6 ; a++ )
    /* for loop execution */
    for (b = 1; b <= a ; b++ )
    printf (“%d”, b);
    printf (“\n”);
    return 0;
  1. 26. Is it possible to use curly brackets ({}) to enclose single line code in C program?
Ans.  Yes, it is working without any error. Some programmers like to use this to organize the code. But the main purpose of curly brackets is to group several lines of codes.  
  1. 27. Describe the modifier in C?
Ans.  Modifier is a prefix to the basic data type which is used to indicate the modification for storage space allocation to a variable.
    Example–In 32-bit processor storage space for int data type is 4.When we use it with modifier the storage space change as follows.
  • • Long int -> Storage space is 8 bit
  • • Short int -> Storage space is 2 bit
  1. 28. What are the modifiers available in C programming language?
Ans. There are 5 modifiers available in C programming language as follows. 
  • • Short
  • • Long
  • • Signed
  • • Unsigned
  • • long long
  1. 29. Is that possible to store 32768 in an int data type variable?
Ans.  Int data type only capable of storing values between – 32768 to 32767.To store 32768 a modifier needs to use with int data type. Long Int can use and also if there is no any negative values unsigned int is also possible to use.  
  1. 30. Is there any possibility to create customized header file with C programming language?
Ans.  It is possible and easy to create a new header file. Create a file with function prototypes that needs to use inside the program. Include the file in ‘#include’ section from its name.  
  1. 31. Describe dynamic data structure in C programming language?
Ans.  Dynamic data structure is more efficient to the memory. The memory access occurs as needed by the program.  
  1. 32. Is that possible to add pointers to each other??
Ans.  There is no possibility to add pointers together. Since pointer contains address details there is no way to retrieve the value from this operation.  
  1. 33. What is indirection?
Ans.  If you have defined a pointer to a variable or any memory object, there is no direct reference to the value of the variable. This is called indirect reference. But when we declare a variable it has a direct reference to the value.  
  1. 34. What is Class ?
Ans.  class is a collection of Data Mamber and Mamber function.  
  1. 35. What is Object ?
Ans.  Object is instance of class.  
  1. 36. What is the difference between overloading and overriding ?
Ans.  Overloading a method (or function) in C++ is the ability for functions of the same name to be defined as long as these methods have different signatures.
Method overriding is the ability of the inherited class rewriting the virtual method of the base class.  
  1. 37. 41What is abstraction?
Ans.  Abstraction refers to hiding the internal implementation and exhibiting only the necessary details.  
  1. 38. What is inheritance?
Ans.  It is we can derive sub class from Super class in other words we can inherit the property of one class to another class.  
  1. 39. What is an inline function?
Ans.  A function prefixed with the keyword inline before the function definition is called as inline function. The inline functions are faster in execution when compared to normal functions as the compiler treats inline functions as macros.  
  1. 40. What is a reference variable in C++?
Ans.  A reference variable is an alias name for the existing variable. Which mean both the variable name and reference variable point to the same memory location. Therefore updating on the original variable can be achieved using reference variable too.  
  1. 41. Explain the static member function.
Ans.  A static member function can be invoked using the class name as it exits before class objects comes into existence. It can access only static members of the class.  
  1. 42. What is a constructor and destructor?
Ans.  A constructor is the member function of the class which is having the same as the class name and gets executed automatically as soon as the object for the respective class is created. Destructor: A destructor is the member function of the class which is having the same name as the class name and prefixed with tilde (~) symbol. It gets executed automatically w.r.t the object as soon as the object loses its scope. It cannot be overloaded and the only form is without the parameters.  
  1. 43. What is a friend function?
Ans.  A function which is not a member of the class but still can access all the member of the class is called so. To make it happen we need to declare within the required class following the keyword ‘friend’.  
  1. 44. What is a class template?
Ans.  A template class is a generic class. The keyword template can be used to define a class template.  

Tips & Tricks

Latest Blog

Which country is better for Indian Students for Study Abroad?17th November, 2018

Canada is one amongst the most effective places to pursue your higher studies and therefore the coun

How to migrate to Canada?17th November, 2018

Have you more experienced necessary facts and options regarding Canada? If no, then you are here at

Study Abroad with Minimum finance17th November, 2018

Some students might wonder how they can study abroad with less money. When they can’t find a spons

How to Become a Good Designer?8th October, 2018

Graphic, Web, Animation, VFX, UI, UX There are plethora of options for a designer to make an amaz

Is Digital Marketing a Right Career For You?2nd October, 2018

Digital Marketing is an industry in itself that is growing rapidly since its inception. And since th

Our Events

Gyanmanjari Institute Of Technology Industrial Visits on 30th June 2018

Gyanmanjari Institute Of Technology Industrial Visits on 30th June at TOPS Technologies TOPS Techno

Android, Laravel, Python, Java and iOS Workshop at TOPS Technology

Android, Laravel, Python, Java and iOS Workshop at TOPS Technology We are happy to share that once

Project Documentation Workshop at TOPS Technologies

Project Documentation Workshop TOPS Technologies have organized “Project documentation” worksho

Final Year Project Documentation Workshop

Final Year Project Documentation Workshop Project Documentation, Project Definition, project Submis

Industrial Visit in the month of March and April at TOPS Technologies

Industrial Visits in the month of March and April at TOPS Technologies TOPS Technologies always bel