C Language Interview Questions and Answers for Freshers - 8

Question: 36

Where should typecast functions not used in C?

Type cast function should not be used in const and volatile declaration.

Because, constant value can’t be modified by the program once they are defined.

And, volatile variables values might keep on changing without any explicit assignment by the program as operating system will be modifying these values.

 

Question: 37

Where is the function declared as static stored in memory?

Yes static keyword would not affect where the function gets stored, even if it is static a function will always be stored in stack. But it hides the function from being used in other files other than in which it is declared.

Question: 38

What is gets() function?

The gets() function allows a full line data entry from the user.

When the user processes the enter key to end the input, the entire line of characters is stored to a string variable.

Note that the enter key is not included in the variable, but instead a null terminator is placed after the last character.

Question: 39

What are static functions?

In C, functions are global by default.

The static keyword before a function name makes it static.

Unlike global functions in C, access to static functions is restricted to the file where they are declared.

Therefore, when we want to restrict access to functions, we make them static.

Another reason for making functions static can be reuse of the same function name in other files.

Question: 40

What is the difference between functions abs() and fabs()?

These two functions basically perform the same action, which is to get the absolute value of the given value.

Abs() is used for integer values, while fabs() is used for floating type numbers. Also the prototype for abs() is under <stdlib.h>, while fabs() is under <math.h>.

Related Questions