- When is the “void” keyword used in a function?
When declaring functions, you will decide whether that function would be returning a value or not. If that function will not return a value, such as when the purpose of a function is to display some outputs on the screen, then “void” is to be placed at the leftmost part of the function header. When a return value is expected after the function execution, the data type of the return value is placed instead of “void”.
- What are actual arguments?
When you create and use functions that need to perform an action on some given values, you need to pass these given values to that function. The values that are being passed into the called function are referred to as actual arguments.
- What are formal parameters?
In using functions in a C program, formal parameters contain the values that were passed by the calling function. The values are substituted in these formal parameters and used in whatever operations as indicated within the main body of the called function.
- Difference between pass by reference and pass by value?
Pass by reference passes a pointer to the value. This allows the callee to modify the variable directly. Pass by value gives a copy of the value to the call. This allows the callee to modify the value without modifying the variable. (In other words, the callee simply cannot modify the variable, since it lacks a reference to it.)
- What is the difference between functions abs () and fabs()?
These 2 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 , while fabs() is under .
- Explain recursive functions? Also explain the advantages and disadvantages of Recursive algorithms?
A recursive function is a function which calls itself. The advantages of recursive functions are:
- A substitute for very complex iteration. For example, a recursive function is best to reduce the code size for Tower of Hanoi application.
- Unnecessary calling of functions can be avoided.
The disadvantages of Recursive functions:
- The exit point must be explicitly coded, otherwise stack overflow may happen
- A recursive function is often confusing. It is difficult to trace the logic of the function. Hence, it is difficult to debug a recursive function.
- What is storage class? What are the different storage classes in C?
Storage class is an attribute that changes the behavior of a variable. It controls the lifetime, scope and linkage. The storage classes in c are auto, register, and extern, static, typedef.
- What is an argument?
An argument is an entity used to pass data from the calling to a called function.
- What are the different storage classes in C?
There are four types of storage classes.
- What is the difference between malloc and calloc?
malloc is use for memory allocation and initialize garbage values.malloc () for allocating the single block of memory.where as calloc is same as malloc but it initialize 0 value.calloc () for allocating multiple blocks of memory.
- 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.