In this post i am sharing C Language Interview Questions and answers. These questions very helpful who are attending written test also. Since You can expect C language programming questions also in written Test. These question also helpful for technical interviews as well. specially who are attending off-campus interviews and for freshers helpful these questions.
1) What is C?
Ans: C is a Structured oriented programming language that was developed in the year 1970's. It was originally used for writing UNIX programs,but now used to write applications for nearly every available platform. C is easier to read,more flexible and more efficient at using memory.
2) Who Developed C programming?
Ans: The inventors of the C programming languages are Ken thompson and Dennis Ritche. The main purpose to develop C programming language is to the development of UNIX Operating System.
3) What is difference Between C and C++?
Ans: Even though C and C+ programming Languages are belonging to middle level languages.
Ans: C language is used to develop system applications that forms major portions of operating systems such as windows,UNIX and Linux. And also Compiler and all Unix application programs are written In C.
Fallowing are the few examples where we used exactly C language:
Ans:
The Following are the Characteristics.
1) What is C?
Ans: C is a Structured oriented programming language that was developed in the year 1970's. It was originally used for writing UNIX programs,but now used to write applications for nearly every available platform. C is easier to read,more flexible and more efficient at using memory.
2) Who Developed C programming?
Ans: The inventors of the C programming languages are Ken thompson and Dennis Ritche. The main purpose to develop C programming language is to the development of UNIX Operating System.
3) What is difference Between C and C++?
Ans: Even though C and C+ programming Languages are belonging to middle level languages.
- C is a Structured/procedural Orient Programming Language whereas C++ is Object Oriented Programming Language.
- C language program design is top-down approach whereas C++ is Bottom-up approach.
- Inheritance,virtual function,polymorphism,name space concepts are not avilable in C whereas C++ language supports all these concepts and fetures.
- C language gives importance to functions rather than data whereas C++ gives importance to the data rather than functions.
- C language does not support user define data types whereas C++ supports user define data types.
- Exception Handling is not present in the C language whereas C++ contains Exceptioin Handling concept.
Ans: C language is used to develop system applications that forms major portions of operating systems such as windows,UNIX and Linux. And also Compiler and all Unix application programs are written In C.
Fallowing are the few examples where we used exactly C language:
- Database systems
- word processors
- spread sheets
- OS
- Network Drivers
- Compilers and Assemblers
- Interpreters
Ans:
The Following are the Characteristics.
- portability
- Reliability
- Flexibility
- Efficiency
- Modularity
6)What is difference between compiler,interpreter and Assembler?
Ans: Assembler is a program that coverts assembly level language into machine level language. Compiler compiles entire C source code into Machine code whereas interpreter converts source code into intermediate code and then this intermediate code is executed line by line.
7) What are the applications of C?
Ans: This language is also called Middle level programming language. C programming can be used to do variety of tasks such as networking related and Operating System related.
8) What are the two forms of #include?
Ans:
1. #include"file name"
2. #include
9) what are the data types in C?
Ans: There are five basic data types associated with variables
1.Integer data type
2.float data type
3.double data type
4.char data type
5.void data type
10) What are input() and output() functions in C?
Ans: The input() function is scanf() function. It is used to read character,string,numeric data from the keyboard. scanf() function is an inbuilt library function which is available in stdio.h header file. The output() function is printf() function. It is used to to print the character,string,float,integer values onto the output screen.This function is also inbuilt library function which is available in stdio.h header file.
11) What is the structure of C Program?
Ans: There are many sections in C program Structure. They are,
Document Section
Link Section
Definition Section
Global Declaration Section
Main function
User defined function section
12) What is IDE?
Ans: IDE stands for Integrated Development Environment. It is a tool that provides user interface with compiler to create,compile and execute C programs. Example: Turbo C++,Borland C++.
13) Is C language is case sensitive?
Ans: YES. C language instructions/functions everything used in c programs are case sensitive.
14) Can you define which header file to include at compiler time?
Ans: This can be done by using the #if,#else,and #endif preprocessor directives.
15) What is Data type in C?
Ans: Data types are defined as the data storage format that a variable can store a data to perform a specific operation. Data types are used to define a variable before to use in a program.
16) How can you tell whether a program was compiled using C or C++?
Ans: The ANSI standard for the C language defines a symbol named _cplusplus that is defined only when you are compiling C++ program. When you are compiling a C program,the _cplusplus symblo is undefined.
17) What is modifier in C?
Ans: The amount of memory space to be allocated for a variable is derived by modifiers. Modifiers are prefixed with basic data types to modify the amount of storage space allocated to a variable.
18) What are the different types of modifiers in C?
Ans: There are 5 modifiers available in C language. They are,
short
long
signed
unsigend
long long
19) What is void in C?
Ans: Void is an empty data type that has no value. We use void data type in functions when we don't want to return any value to the calling function.
Example: void add(int x,int y); this function won't return any value to the calling function
int add( int x,int y); this function return value to the calling function
20) What is token in C?
Ans: C tokens are basic buildings blocks in C language which are constructed together to write a C program. Each and every smallest individual unit in a c program are known as C tokens.
21) What is the use of sizeof() function in C?
Ans: This functions is used to find the memory space allocated for each data type in C.
22) What is static memory allocation and dynamic memory allocation?
Ans:
Static Memory allocation: The compiler allocates the required memory space for a declared variable. By using the address of operator,the reserved address is obtained and this address may be assigned to a pointer variable. Since most of the declared variable have static memory,this way of assigning pointer value to a pointer variable is known as static memory allocation. Memory is assigned during compilation time.
Dynamic memory allocation:It uses functions such as malloc() or calloc() to get memory dynamically. If these functions are used to get memory dynamically and the values returned by these functions are assigned to pointer variables such assignments are known as dynamic memory allocation.
23) How are pointer variables initialized?
Ans: Pointer variable are initialized by one of the fallowing two ways:
Static memory allocation
Dynamic memory allocation
24) Difference Between arrays and pointers?
Ans: Pointers are used to manipulate data using the address. Pointers use * operator to access the data pointed to by them. Arrays use sub-scripted variables to access and manipulate data. Array variables can be equivalently written using pointer expression.
25) What is pointer variable?
Ans: A pointer variable is a variable that may contain the address of another variable or any valid address in the memory.
26)Can static variables be declared in a header file?
Ans: You can't declare a static variable without defining it as well. A static variable can be defined in a header file,but this would cause each source file that included the header file to have its own private copy of the variable,which is probably not what was intended.
27) How can you determine the size of an allocated portion of memory?
Ans: You can't,really. free() can,but there's no way for your program to know the trick free() uses. Even if you disassemble the library and discover the trick,there's no guarantee the trick won't change with the next release of the compiler.
28) What is difference between strings and character arrays?
Ans: String will have static storage duration,whereas as a character array will not,unless it is explicitly specified by using the static keyword.
29) what is difference between malloc() and calloc()?
Ans: There are two differences, First,is in the number of arguments. malloc() takes a single argument(memory required in bytes),while calloc()needs 2 arguments(number of variables to allocate memory,size in bytes of a single variable). Secondly,malloc() does not initialize the memory allocated,while calloc() initializes the allocated memory to ZERO.
30) What is exit() function in C?
Ans: exit() function terminates the program normally and returns the status code to the parent program.
Syntax: void exit(int status)
Ans: Assembler is a program that coverts assembly level language into machine level language. Compiler compiles entire C source code into Machine code whereas interpreter converts source code into intermediate code and then this intermediate code is executed line by line.
7) What are the applications of C?
Ans: This language is also called Middle level programming language. C programming can be used to do variety of tasks such as networking related and Operating System related.
8) What are the two forms of #include?
Ans:
1. #include"file name"
2. #include
9) what are the data types in C?
Ans: There are five basic data types associated with variables
1.Integer data type
2.float data type
3.double data type
4.char data type
5.void data type
10) What are input() and output() functions in C?
Ans: The input() function is scanf() function. It is used to read character,string,numeric data from the keyboard. scanf() function is an inbuilt library function which is available in stdio.h header file. The output() function is printf() function. It is used to to print the character,string,float,integer values onto the output screen.This function is also inbuilt library function which is available in stdio.h header file.
11) What is the structure of C Program?
Ans: There are many sections in C program Structure. They are,
Document Section
Link Section
Definition Section
Global Declaration Section
Main function
User defined function section
12) What is IDE?
Ans: IDE stands for Integrated Development Environment. It is a tool that provides user interface with compiler to create,compile and execute C programs. Example: Turbo C++,Borland C++.
13) Is C language is case sensitive?
Ans: YES. C language instructions/functions everything used in c programs are case sensitive.
14) Can you define which header file to include at compiler time?
Ans: This can be done by using the #if,#else,and #endif preprocessor directives.
15) What is Data type in C?
Ans: Data types are defined as the data storage format that a variable can store a data to perform a specific operation. Data types are used to define a variable before to use in a program.
16) How can you tell whether a program was compiled using C or C++?
Ans: The ANSI standard for the C language defines a symbol named _cplusplus that is defined only when you are compiling C++ program. When you are compiling a C program,the _cplusplus symblo is undefined.
17) What is modifier in C?
Ans: The amount of memory space to be allocated for a variable is derived by modifiers. Modifiers are prefixed with basic data types to modify the amount of storage space allocated to a variable.
18) What are the different types of modifiers in C?
Ans: There are 5 modifiers available in C language. They are,
short
long
signed
unsigend
long long
19) What is void in C?
Ans: Void is an empty data type that has no value. We use void data type in functions when we don't want to return any value to the calling function.
Example: void add(int x,int y); this function won't return any value to the calling function
int add( int x,int y); this function return value to the calling function
20) What is token in C?
Ans: C tokens are basic buildings blocks in C language which are constructed together to write a C program. Each and every smallest individual unit in a c program are known as C tokens.
21) What is the use of sizeof() function in C?
Ans: This functions is used to find the memory space allocated for each data type in C.
22) What is static memory allocation and dynamic memory allocation?
Ans:
Static Memory allocation: The compiler allocates the required memory space for a declared variable. By using the address of operator,the reserved address is obtained and this address may be assigned to a pointer variable. Since most of the declared variable have static memory,this way of assigning pointer value to a pointer variable is known as static memory allocation. Memory is assigned during compilation time.
Dynamic memory allocation:It uses functions such as malloc() or calloc() to get memory dynamically. If these functions are used to get memory dynamically and the values returned by these functions are assigned to pointer variables such assignments are known as dynamic memory allocation.
23) How are pointer variables initialized?
Ans: Pointer variable are initialized by one of the fallowing two ways:
Static memory allocation
Dynamic memory allocation
24) Difference Between arrays and pointers?
Ans: Pointers are used to manipulate data using the address. Pointers use * operator to access the data pointed to by them. Arrays use sub-scripted variables to access and manipulate data. Array variables can be equivalently written using pointer expression.
25) What is pointer variable?
Ans: A pointer variable is a variable that may contain the address of another variable or any valid address in the memory.
26)Can static variables be declared in a header file?
Ans: You can't declare a static variable without defining it as well. A static variable can be defined in a header file,but this would cause each source file that included the header file to have its own private copy of the variable,which is probably not what was intended.
27) How can you determine the size of an allocated portion of memory?
Ans: You can't,really. free() can,but there's no way for your program to know the trick free() uses. Even if you disassemble the library and discover the trick,there's no guarantee the trick won't change with the next release of the compiler.
28) What is difference between strings and character arrays?
Ans: String will have static storage duration,whereas as a character array will not,unless it is explicitly specified by using the static keyword.
29) what is difference between malloc() and calloc()?
Ans: There are two differences, First,is in the number of arguments. malloc() takes a single argument(memory required in bytes),while calloc()needs 2 arguments(number of variables to allocate memory,size in bytes of a single variable). Secondly,malloc() does not initialize the memory allocated,while calloc() initializes the allocated memory to ZERO.
30) What is exit() function in C?
Ans: exit() function terminates the program normally and returns the status code to the parent program.
Syntax: void exit(int status)