Top 45 C programming interview questions and answers


In this article, you will find basic to most puzzled interview queries questions. This article is very useful for those who are preparing for an interview in IT company. Whether you are experienced or fresher, this article will cover all C programming interview questions from basic to advanced level.

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

1) Describe some features of C language.
  1. C has the features of both high and low-level programming languages.
  2. Supports machine independence, the code you compile in one computer can be executed in another machine without any error.
  3. C is a procedural language and supports modular programming.
  4. C is a well-structured programming language which is used to write efficient programs.
2) What is the basic syntax of a C program?
#include <stdio.h>
void main(void) {
printf("Hello World");             //printing a string
3) What is preprocessor directive?

A preprocessor directive starts from # in C and is used to modify C program. The preprocessor directive is not a part of the compiler but is an instruction to compiler before the program is executed to include header files. In short, pre-processing is done when # is used.

4) What are the different types of comments in C programming?

In C programming, we have:

  1. Single line comments
  2. Multi-line comments

Single line comment in C can be added using double slash //.

// This is Single line comment

Multi-Line comments in C can be added using /* at beginning and */ and ending of the comment.

/* This is
Multi line comment */

5) What is the difference between keyword and Identifier?

Keywords are the reserved words that are predefined and have special meaning and purpose whereas, identifiers are the names of user-defined functions, variables, and constants, etc.


6) What is the difference between variable and constant?

A variable is the one whose value can be changed as the name says during the execution of the program. The value of a constant cannot be changed once it is defined.

7) List and describe the use of some of the keywords in C programing language.

The following are some of the keywords in C:

while: is used to use the while loop in C.
default: is used in switch statement. When all the cases are false, the default part is executed.
int: is used to declare a variable of integer type.
void: is a data type which means nothing.

8) What are the data types in C programming? Give example.

When declaring variables data types are used to specify the type of the variable and to reserve space in memory according to type of variable. The following are some of the data types in C:

  1. Basic data types which include: int, long, double, float, char, etc.
  2. Void type which means nothing
  3. Derived types for example arrays, and structures, etc.
9) What is variable declaration?.

To specify the data type and name of variable is called variable declaration. A variable can be declared in C as follows:

int blue;

Here int is data type and blue is the name of variable.

10) What is variable definition?

Declaring and initializing a variable is called definition of variable.

11) Can you declare variables of same name?

Variables in same scope cannot have same name but variables in different scope can have same names.

12) How you can display data on output screen in C?

In C programming, data can be displayed on output screen using printf() statement. The syntax of printf() is as follows:

printf("format string", variableName);

format string can have a message that you want to display and format specifiers and escape sequences. Format specifiers are for value of variable.

format string can have a message that you want to display and format specifiers and escape sequences. Format specifiers are for value of variable.

13) How you can read something from the output screen?

You can get user input by using the scanf() statement. The syntax of scanf() is as follows:

scanf("format string", &variableName);

14) How you can read strings from the output screen and display strings on output string?

Strings can be read from output screen by using the gets() function and you can display strings on output screen by using puts() statement.

15) Why & operator is used?

The & operator is an address operator. The & operator ensures to store the entered value into the corresponding memory location.


« 1 2 3 »  

Popular Posts


Founded in 2016, Tech Study passionately delivers stylish and dynamic innovative information to programmer & technology lovers.