C Functions Interview Preparation Guide
Download PDF

C Language Functions frequently Asked Questions in various C functions job Interviews by interviewer. The set of questions here ensures that you offer a perfect answer posed to you. So get preparation for your new job hunting

45 C Functions Questions and Answers:

Table of Contents:

C Functions Interview Questions and Answers
C Functions Interview Questions and Answers

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.

9 :: Are the variables argc and argv are always local to main?

Yes they are local to main.

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.

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.

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.