C interview questions

C language is one of the most complete programming software with more advantages instead disadvantages, this language have an infinitive kind of uses, the possibility of questions are infinitive too. If you have been considered for a C interview, you must take care of your preparation.

C interview questions

There are several techniques and tips that you must know before an interview. We recommend obtain all the possible information about the company, a good way to start is on the web and if you have some friend that is working in the same company it is advisable ask him for information.

The next step is the preparation, C interview questions sometimes are very difficult, and the level of difficult will depend about the company and what they do, most people forget or don't give enough time to the preparation.

C interview questions are a type of test with complicated questions and directly related with the company or the job that you are applying. There is not a set format of questions, but the most probably questions that are going to be taken from your resume. By the way there are several common questions that could be taken.

In the next information we have listed the most common questions and answers classified in 3 themes:

  • Variables & Control Flow
  • Operators, constants and structures
  • Functions

Variables & Control Flow

It is referred with different variables and control flow statements such as if-else statements, loop statements, for, while and even more, In this section you will find the most possible and common questionsthat could be considered in an interview.

What is the difference between declaring a variable and defining a variable?

Declaration of a variable in C hints the compiler about the type and size of the variable in compile time. Similarly, declaration of a function hints about type and size of function parameters. No space is reserved in memory for any variable in case of declaration.

What is a static variable?

Astatic variable is a special variable that is stored in the data segment unlike the default automatic variable that is stored in stack. A static variable can be initialized by using keyword static before variable name.

What is a register variable?

Register variables are stored in the CPU registers. Its default value is a garbage value. Scope of a register variable is local to the block in which it is defined. Lifetime is till control remains within the block in which the register variable is defined.

Where is an auto variables stored?

Main memory and CPU registers are the two memory locations where auto variables are stored. Auto variables are defined under automatic storage class. They are stored in main memory. Memory is allocated to an automatic variable when the block which contains it is called and it is de-allocated at the completion of its block execution.

Auto variables:

  • Storage:main memory.
  • Default value:garbage value.
  • Scope:local to the block in which the variable is defined.
  • Lifetime:till the control remains within the block in which the variable is defined.

Operators, constants and structures

In all types of languages are used, the variables and the constants are used to save data, the structures are used to control the flow of the software and the structures are used to generate the repetition of the instruction. The next questions and answers listed are going to be helpful.

What are the advantages of using unions?

Union is a collection of data items of different data types.It can hold data of only one member at a time though it has members of different data types.If a union has two members of different data types, they are allocated the same memory. The memory allocated is equal to maximum size of the members. The data is interpreted in bytes depending on which member is being accessed.

What mean the structure If-Then-Else?

This structuremeansa condition,to runornotexecute a particulartask orline of code.

What mean the structure while-wend?

Thiscontrol structurewill repeatwithout stoppinga certaincode whilea condition is met.

How can typedef be to define a type of structure?

typedef declaration helps to make source code of a C program more readable. Its purpose is to redefine the name of an existing variable type. It provides a short and meaningful way to call a data type. typedef is useful when the name of the data type is long. Use of typedef can reduce length and complexity of data types.


In C every programming language has an equivalent of a function, using a function we can create a big structure. Please review all the possible information about functions.

What is the purpose of main() function?

In C, program execution starts from the main() function. Every C program must contain a main() function. Themain function may contain any number of statements. These statements are executed sequentially in the orderwhich they are written.

What is recursion? Write a program using recursion (factorial)?

Recursion: A function is called 'recursive' if a statement within the body of a function calls the same function. It is also called 'circular definition'. Recursion is thus a process of defining something in terms of itself.

Explain command line arguments of main function?

In C, we can supply arguments to 'main' function. The arguments that we pass to main ( ) at command prompt are called command line arguments. These arguments are supplied at the time of invoking the program.

The main ( ) function can take arguments as: main(intargc, char *argv[]) { }

The first argument argc is known as 'argument counter'. It represents the number of arguments in the command line. The second argument argv is known as 'argument vector'. It is an array of char type pointers that points to the command line arguments. Size of this array will be equal to the value of argc.

What is Pass by Reference?

Pass by Reference: In this method, the addresses of actual arguments in the calling function are copied into formal arguments of the called function. This means that using these addresses, we would have an access to the actual arguments and hence we would be able to manipulate them.

This is just a bit of the large possible questions, Review information about pointers and programs in C.