Interview Questions for C Programming

C Programming language was developed between 1969 and 1973 by Dennis Ritchie at Bell Labs. He uses this new programming language to re-implement UNIX operating system.

C is a high-level structured oriented programming language used for general-purpose programming requirements. Basically, C is a collection of its library functions. It is also flexible to add user-defined functions and include those in the C library.

The main usage of C programming language includes Language Compilers, Operating Systems, Assemblers, Text Editors, Print Spoolers, Network Drivers, Modern Programs, Data Bases, Language Interpreters, and Utilities.

If you’re preparing for a C language interview questions and answers , then you’ve landed at the right spot. Here are some best C interview questions to help you get going for that job interview or to simply self-assess how good you’ve gotten with the general-purpose, procedural programming language:

Q1). What is C Programming Language?

**Ans:**C is an imperative procedural Programming language. This is designed by Dennis Ritchie. C was originally developed by Dennis Ritchie between 1969 and 1973 at AT & T Bell Labs. C Language was first appeared in 1972. It was mainly developed as a system programming language to write OS (operating system).

Q2). Write some features of C Programming Language.

Ans: The features of the C programming Language are:

  • Portability: It means that we can easily run programs written on one platform on the other platform. Ex- A sum of number programs written on Turbo C++ can run on Codeblocks.

  • Simple: Simple is also a feature of C programming language because it is very easy to learn and understand the programming concepts and build the logics.

  • Memory Management: Memory management is also a good features of c programming language. It supports both static as well as dynamic memory allocation. Using the concept of dynamic memory allocation we can allocate memory as per requirement and can free useless allocated memory space by calling free() function.

  • Speed: The compilation and execution time of the c language is fast as compared to other programming languages like Python or Java.

  • Case Sensitive: The meaning of both Upper and Lower case letters is different. EX: If we assign value 4 to lowercase x and try to access with uppercase X then we encounter error.

  • Rich Library: C language has a lot of in-built functions which makes development fast.

Q3). What do you mean by Data Type in C?

**Ans:**Data Type defines which type of value a variable can store. In C programming language each variable is associated with a data type and each data type requires different size of memory.Some most usable data type:char: char shows the variable of type char stores single character. char requires a one byte of memory. Ex: char ch;Here ch is variable and having data type “char”.int: int shows the variable having data type int stores integer value. int requires a four byte of memory. Ex: int i;here i is variable of type integers.float: float is used to store decimal numbers with single precision. float requires a four byte of memory. **Ex:**float f;Here f is variable of type float.double: double is used to store decimal numbers with double precision. Ex: double d;Here d is variable of type double.

Q4). How many types of data type in C Language?

**Ans:**C language supports 2 type of data types: **a). Primary data types:**Primary data types are known as fundamental data types.Some primary data types are integer(int), floating point(float), character(char) and void.

 **b).Derived data types:**Derived data types are derived from primary datatypes. Some derived data types are array, structure, union and pointer.

Q5). What is constant and variable in C .

Ans:

Constant: A constant is a value or an identifier whose value cannot be changed in a program. identifier also can be defined as a constant. **For example:**const double PI = 3.14Here, PI is a constant. And the PI contains 3.14 for this program.VariablesA variables is a value or an identifier whose value can be changed in a program. Variable is a container to hold data. **For example:**int score = 6;Here, score is a variable of integer type and it contains value 6. The value of score can be change so here score is variable.

Q6) What is the use of printf() and scanf() functions?

Ans: printf(): The printf() function is used to print values on to the screen(console). Value may be anythings like integer, float, character and string. **scanf():**The scanf() function is used to take input from the user.

Q7). What is the difference between the local variable and global variable in C.

Ans:

local variable: It is defined inside a function. It is accessible only in the function in which it is defined.

Global variable : It is defined outside of all the functions in a program. It is available to all the functions in the program.

Q8) Write format specifiers in C.

Ans: %d: It is used to print an integer value. %s: It is used to print a string. %c: It is used to display a character value. %f: It is used to display a floating point value.

Q9) How many spaces a Tab has in C.

Ans: A Tab has 8 spaces.

Q10) What is static variable in C? What is its use?

**Ans:**static keyword is used to declared static variable. Static variables preserves their value outside of their scope. Hence, static variables preserve their previous value in their previous scope and are not initialized again in the new scope.Scope of the static variable is available in the entire program. So, we can access a static variable anywhere in the program.The initial value of the static variable is zero. The static variable shares common value with all the methods.The static variable is initialized only once in the memory heap to reduce the memory usage.

The questioner is based on the C programming language concepts , the knowledge of its syntax and some example programs that use the Basic C program structure. If you want to polish your C programming skills before the interview, feel free to check out these best C tutorials and this C Programming course.



1

Posts

54

Views