Functions Interview Questions

    Question 1Purpose of Functions

    What is the main advantage of using functions in C?

    Question 2Built-in Functions

    Which of the following is a standard library function in C?

    Question 3Function Declaration

    Where is a function prototype (declaration) usually placed in a C program?

    Question 4Return Type

    What does a function return if its return type is not specified in C (default)?

    Question 5Function with Parameters

    What will be the output?

    #include <stdio.h> int add(int a, int b) { return a + b; } int main() { printf("%d", add(3, 4)); return 0; }

    Question 6Function Call by Value

    What will be printed?

    #include <stdio.h> void change(int x) { x = 100; } int main() { int a = 5; change(a); printf("%d", a); return 0; }

    Question 7Recursive Function

    Which of the following functions is an example of recursion?

    Question 8Recursion Example

    What is the output of the following code?

    #include <stdio.h> int fact(int n) { if (n == 0) return 1; return n * fact(n - 1); } int main() { printf("%d", fact(3)); return 0; }

    Question 9Standard Library Header

    Which header file must be included to use sqrt() function?

    Question 10Void Functions

    What is true about a void function in C?