Google News
logo
C-Language Interview Questions
There are 3 types of decision making control statements in C language. They are :

if statements
if else statements
nested if statements
Loop control statements in C are used to perform looping operations until the given condition is true. Control comes out of the loop statements once condition becomes false.

There are 3 types of loop control statements in C language. They are : 

for
while
do-while
While loop is executed only when given condition is true.
Whereas, do-while loop is executed for first time irrespective of the condition. After executing while loop for first time, then condition is checked.
NULL is a macro which is defined in C header files. The value of NULL macro is 0. It is defined in C header files as below.

#define NULL (void *) 0;

NULL is used for pointers only as it is defined as (void *) 0. It should not be used other than pointers. If NULL is assigned to a pointer, then pointer is pointing to  nothing.
Dynamic data structure provides a means for storing data more efficiently into memory. Using dynamic memory allocation, your program will access memory spaces as needed. This is in contrast to static data structure, wherein the programmer has to indicate a fix number of memory space to be used in the program.
C Structure is a collection of different data types which are grouped together and each element in a C structure is called member.

In real life we need to have different data types for ex: To maintain employee information. We should have information such as name, age, qualification, salary etc. here to maintain the information of employee dissimilar data types required. Name & qualification are char data type, age is integer, and salary is float. You can create this information separately but, better approach will be collection of this information under single name because all these information are related to person.
Unions are conceptually similar to structures. The syntax of union is also similar to that of structure. The only difference is in terms of storage. In structure each  member has its own storage location, whereas all members of union use a single shared memory location which is equal to the size of its largest data member.

Example :
      union item 
      {
      int m;
      float x;
      char c;
      }It1;
Enumeration data type used to symbolize a list of constants with valid meaningful names, so that, it makes the program easy to read and modify. Enumeration has advantage of generating the values automatically for given list of names. Keyword enum is used to define enumerated data type.

Syntax : 
  enum type_name
  { 
   value1, value2... valueN 
   };
For every c program it is required to have a proper error handling mechanism that can deal with errors which occur at runtime. Error handling is the process of  responding to the occurrence of any error that occurs during the computation, of exceptions.

errno, perror() and strerror() : 

In C Programming Language we have perror() and strerror() functions which can be used to display the text message associated with errno.

perror() :  It displays the string you pass to it, followed by a colon, a space, and then the textual representation of the current errno value.
strerror() : It returns a pointer to the textual representation of the current errno value.
stderr : It is file stream to output the errors.
A file is a place on disk where group of related data are stored. C supports a number of functions that have the ability to perform basic file operations, which  include : 

Creating a new file
Opening a file 
Reading data from a file 
Writing data to a file 
Closing the file