1. What are C identifiers?

These are names given to various programming element such as variables, function, arrays.It is a combination of letter, digit and underscore.It should begin with letter. Backspace is not allowed.

2. What is logical error?

Logical error are caused by an incorrect algorithm or by a statement mistypes in such a way
► That it doesn't violet syntax of language.
► Difficult to find.

3. Can you please explain the difference between syntax vs logical error?

Syntax Error
► These involves validation of syntax of language.
► Compiler prints diagnostic message.
Logical Error
Logical error are caused by an incorrect algorithm or by a statement
► Mistyped in such a way that it doesn't violet syntax of language.
► Difficult to find.

4. Can we use any name in place of argv and argc as command line arguments?

yes we can use any user defined name in place of argc and argv.

5. What is recursion?

A recursion function is one which calls itself either directly or indirectly it must halt at a definite point to avoid infinite recursion.

6. What is actual argument?

Actual arguments are available in the function call. These arguments are given as constants or variables or expressions to pass the values to the function.

7. What is formal argument?

Formal arguments are the arguments available in the function definition. They are preceded by their own data type.

8. Can main () be called recursively?

Yes any function including main () can be called recursively.

10. Do you know the use of "auto" keyword?

When a certain variable is declared with the keyword 'auto' and initialized to a certain value, then within the scope of the variable, it is reinitialized upon being called repeatedly.

Download Interview PDF

11. Do you know the purpose of "register" keyword?

It is used to make the computation faster.
The register keyword tells the compiler to store the variable onto the CPU register if space on the register is available. However, this is a very old technique. Todays processors are smart enough to assign the registers themselves and hence using the register keyword can actually slowdown the operations if the usage is incorrect.

12. What are the scope of static variables?

The scope of a static variable is local to the block in which the variable is defined. However, the value of the static variable persists between two function calls.

13. What is use of bit field?

Bit Fields allow the packing of data in a structure. This is especially useful when memory or data storage is at a premium.

14. Explain bitwise shift operators?

The bitwise operators are used for shifting the bits of the first operand left or right. The number of shifts is specified by the second operator.

15. Can you please explain the difference between exit() and _exit() function?

► Io buffers are flushed by exit() and executes some functions those are registered by atexit().
► _exit() ends the process without invoking the functions which are registered by atexit().

16. What is _exit() function?

_exit() does not cleanup work like closing file descriptor, file stream and so on.

17. What is exit() function?

exit() does cleanup work like closing file descriptor, file stream and so on.

18. Can you please explain the difference between strcpy() and memcpy() function?

► Memcpy() copies specific number of bytes from source to destinatio in RAM, where as strcpy() copies a constant / string into another string.
► Memcpy() works on fixed length of arbitrary data, where as strcpy() works on null-terminated strings and it has no length limitations.
► Memcpy() is used to copy the exact amount of data, whereas strcpy() is used of copy variable-length null terminated strings.

19. What is memcpy() function?

With memcopy(), the programmer needs to specify the size of data to be copied. strncpy() is similar to memcopy() in which the programmer specifies n bytes that need to be copied.

20. What is strcpy() function?

strcpy() copies a string until it comes across the termination character ''.

21. Can you please explain the difference between malloc() and calloc() function?

Both functions are used to dynamically allocate the memory.

22. What is malloc() function?

malloc contains garbage values.

23. What is calloc() function?

calloc initializes the allocated memory to 0 or Null.

24. What is fflush() function?

In ANSI, fflush() [returns 0 if buffer successfully deleted / returns EOF on an error] causes the system to empty the buffer associated with the specified output stream.

Download Interview PDF

25. What is function prototype?

A function prototype is a mere declaration of a function. It is written just to specify that there is a function that exists in a program.

26. What is C standard library?

The C standard library is the standard library for the C programming language, as specified in the ANSI C standard. It was developed at the same time as the C POSIX library, which is a super-set of it.

27. What is the scope of static variables in C Language?

Static variables in C have the scopes;

1. Static global variables declared at the top level of the C source file have the scope that they can not be visible external to the source file. The scope is limited to that file.

2. Static local variables declared within a function or a block, also known as local static variables, have the scope that, they are visible only within the block or function like local variables. The values assigned by the functions into static local variables during the first call of the function will persist / present / available until the function is invoked again.

The static variables are available to the program, not only for the function / block. It has the scope within the current compile. When static variable is declared in a function, the value of the variable is preserved , so that successive calls to that function can use the latest updated value. The static variables are initialized at compile time and kept in the executable file itself. The life time extends across the complete run of the program.

Static local variables have local scope. The difference is, storage duration. The values put into the local static variables, will still be present, when the function is invoked next time.

28. What is C Programming structure?

Structures provide a convenient method for handling related group of data of various data types.

Structure definition:

struct tag_name
{
data type member1;
data type member2;


}

Example:
struct library_books
{
char title[20];
char author[15];
int pages;
float price;
};

The keyword struct informs the compiler for holding fields ( title, author, pages and price in the above example). All these are the members of the structure. Each member can be of same or different data type.

The tag name followed by the keyword struct defines the data type of struct. The tag name library_books in the above example is not the variable but can be visualized as template for the structure. The tag name is used to declare struct variables.

Ex: struct library_books book1,book2,book3;

The memory space is not occupied soon after declaring the structure, being it a template. Memory is allocated only at the time of declaring struct variables, like book1 in the above example. The members of the structure are referred as - book1.title, book1.author, book1.pages, book1.price.

Unions

Unions are like structures, in which the individual data types may differ from each other. All the members of the union share the same memory / storage area in the memory. Every member has unique storage area in structures. In this context, unions are utilized to observe the memory space. When all the values need not assign at a time to all members, unions are efficient. Unions are declared by using the keyword union , just like structures.

Ex: union item {
int code;
float price;
};

The members of the unions are referred as - book1.title, book1.author, book1.pages, book1.price.

29. What is self-referential structure in C Programming?

A self-referential structure is one of the data structures which refer to the pointer to (points) to another structure of the same type. For example, a linked list is supposed to be a self-referential data structure. The next node of a node is being pointed, which is of the same struct type. For example,

typedef struct listnode {
void *data;
struct listnode *next;
} linked_list;

In the above example, the listnode is a self-referential structure – because the *next is of the type sturct listnode.

30. Explain the use of "auto" keyword in C Programming?

The keyword ‘auto' is used extremely rare. A variable is set by default to auto. The declarations:

auto int number; and int number;

has the same meaning. The variables of type static, extern and register need to be explicitly declared, as their need is very specific. The variables other than the above three are implied to be of ‘auto' variables. For better readability auto keyword can be used.

31. Do you know what are the properties of Union in C?

A union is utilized to use same memory space for all different members of union. Union offers a memory section to be treated for one variable type , for all members of the union. Union allocates the memory space which is equivalent to the member of the union , of large memory occupancy.

32. Tell me what is the purpose of "register" keyword in C Language?

The keyword ‘register' instructs the compiler to persist the variable that is being declared , in a CPU register.

Ex: register int number;

The persistence of register variables in CPU register is to optimize the access. Even the optimization is turned off; the register variables are forced to store in CPU register.

33. What is the difference between strcpy() and memcpy() function in C Programming?

The following are the differences between strcpy() and memcpy():

- memcpy() copies specific number of bytes from source to destinatio in RAM, where as strcpy() copies a constant / string into another string.

- memcpy() works on fixed length of arbitrary data, where as strcpy() works on null-terminated strings and it has no length limitations.

- memcpy() is used to copy the exact amount of data, whereas strcpy() is used of copy variable-length null terminated strings.

34. Do you know what is the purpose of "extern" keyword in a function declaration?

The keyword ‘extern' indicates the actual storage of the variable is visible , or body of a function is defined elsewhere, commonly in a separate source code. This extends the scope of the variables or functions to be used across the file scope.

Example:
extern int number;

35. What is the difference between malloc() and calloc() function in C Language?

The following are the differences between malloc() and calloc():

- Byte of memory is allocated by malloc(), whereas block of memory is allocated by calloc().

- malloc() takes a single argument, the size of memory, where as calloc takes two parameters, the number of variables to allocate memory and size of bytes of a single variable

- Memory initialization is not performed by malloc() , whereas memory is initialized by calloc().

- malloc(s) returns a pointer with enough storage with s bytes, where as calloc(n,s) returns a pointer with enough contiguous storage each with s bytes.