C Interview Questions and Answers

In this article, we are sharing the most common C programming interview questions and answers which helps you to crack your next interviews.

C Interview Questions and Answers:

1. How to reverse a sentence with a program?

Ans: This is a very simple program having the following logic.

2. What is the difference between character array and string in C?

Ans: Below are the comparison table to shows the difference between character array and string in c programming language.

 

Basis for ComparisonCharacter ArrayString
BasicCharacter array is collection of variables, of character data type.String is class and variables of string are the object of class “string”.
Syntaxchar array_name [size];string string_name;
IndexingAn individual character in a character array can be accessed by its index in array.In string the particular character can be accessed by the function “string_name.charAt(index)”.
Data TypeA character array does not define a datatype.A string defines a datatype in C++.
OperatorsOperators in C++ can not be applied on character array.You may apply standard C++ operator on the string.
BoundaryArray boundaries are easily overrun.Boundaries will not overrun.
AccessFast accessing.Slow accessing.

3.Write a program to reverse a linked list?

Ans: Below is the program to reverse a linked list.

4. How will you change the value of a constant variable in C?

Ans: Constant can be changed by using the pointer. Initialize a pointer to point to the value of a and then change the value using the pointer. See the below c program.

5. What are the key features in the C programming language?
Ans: Below are the key features of 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 compared with other high-level languages.
  • Extensibility – Possibility to add new features by the programmer.

6. What are the basic data types associated with C?

Ans: Following are the basic data types associated with C:

  • Int – Represent the number (integer)
  • Float – Number with a fraction part.
  • Double – Double-precision floating-point value
  • Char – Single character
  • Void – Special purpose type without any value.

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

If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.

Recommended Posts:


Editorial Staff

Editorial Staff at FreeWebMentor is a team of professional developers.

Comments and Discussions

Your email address will not be published. Required fields are marked *