Why our notes

Built for Fast, Smart Revision

Everything is designed to save your time and lift your score.

✂️

Zero Fluff Summaries

Only exam-relevant points in short, crisp lines, so every minute of study counts.

🗺️

Flowcharts & Visual Timelines

Mind maps, flowcharts and timelines turn heavy topics into pictures you remember.

🎯

PYQ-Linked Key Points

Key points are linked to previous-year question trends so you know what matters most.

📱

Accessible on All Devices

Read on phone, tablet or laptop, or print a clean copy with the print-friendly layout.

Free Study Articles & Updates

Top 50 VIVA Questions and Answers: Mastering Functions in C Language

 Top 50 VIVA Questions and Answers: Mastering Functions in C Language

Top 50 VIVA Questions and Answers: Mastering Functions in C Language


Gear up for your C programming VIVA with confidence! Explore our curated list of the top 50 VIVA questions and detailed answers on functions. Covering everything from basic function concepts to advanced topics like recursion, pointers, and function templates, this comprehensive guide is designed to sharpen your understanding. Whether you're preparing for an interview or reinforcing your C programming skills, these questions will pave the way for success. Elevate your knowledge and tackle VIVA sessions with ease!

VIVA Questions and Answers:

1. What is a function in C?

  • A function is a self-contained block of code that performs a specific task and can be called from other parts of the program.

2. How is a function declared in C?

  • A function is declared by specifying its return type, name, and parameters (if any).

3. Explain the purpose of the return type in a function declaration.

  • The return type specifies the type of value that the function will return after its execution.

4. What is a function prototype, and why is it used?

  • A function prototype declares the function's signature, including its return type and parameters. It is used to inform the compiler about the function's existence before its actual implementation.

5. How is a function called in C?

  • A function is called by using its name followed by parentheses, and arguments (if any) are passed within the parentheses.

6. Discuss the significance of function parameters.

  • Function parameters are variables used to pass values to a function. They allow functions to work with different data each time they are called.

7. What is the purpose of the return statement in a function?

  • The return statement is used to exit a function and optionally return a value to the calling code.

8. Differentiate between call by value and call by reference.

  • In call by value, function parameters receive copies of the arguments. In call by reference, function parameters receive references (memory addresses) to the actual arguments.

9. How do you declare a function that does not return any value?

  • Use the void keyword as the return type in the function declaration.

10. Explain the role of local variables in a function. - Local variables are declared within a function and can only be accessed within that function. They are not visible outside the function.

11. What is function overloading? - Function overloading allows multiple functions with the same name but different parameter lists or types. The compiler determines the correct function to call based on the context.

12. How are default arguments implemented in C functions? - Default arguments are specified in the function prototype. If a corresponding argument is not provided during the function call, the default value is used.

13. Discuss the purpose of a static variable in a function. - A static variable in a function retains its value between function calls. It is initialized only once during the first call.

14. How is recursion implemented in C functions? - Recursion is the process where a function calls itself. A base case is necessary to prevent infinite recursion.

15. Explain the concept of a function pointer. - A function pointer is a variable that stores the address of a function. It can be used to call functions dynamically.

16. What is the scope of a global variable in C? - A global variable can be accessed by any function in the program. It has global scope.

17. Discuss the importance of the extern keyword in function declarations. - The extern keyword is used to declare a function without defining it. It informs the compiler that the function is defined elsewhere.

18. What is a recursive function? - A recursive function is a function that calls itself. It must have a base case to stop the recursion.

19. How is variable scope determined in C functions? - Variables in C have either local scope (within a function) or global scope (accessible throughout the program).

20. Explain the concept of function prototyping. - Function prototyping involves declaring the function's signature (return type, name, and parameters) before its actual implementation.

21. What is the significance of the static keyword in function parameters? - The static keyword in function parameters means that the parameter retains its value between function calls.

22. Discuss the use of a header file in C functions. - Header files in C contain function prototypes and declarations. They are included in source files to provide information to the compiler.

23. How do you pass an array to a function in C? - An array is passed to a function by specifying the array name as a parameter. The size of the array is optional.

24. What is the role of the const keyword in function parameters? - The const keyword in function parameters indicates that the parameter value cannot be modified within the function.

25. How are functions defined in a separate file in C? - Functions can be defined in a separate file, and their prototypes are included in a header file. The header file is then included in the main program.

26. Explain the purpose of the inline keyword in C functions. - The inline keyword suggests to the compiler to perform inline expansion of the function, replacing the function call with the actual code.

27. What is a variadic function in C? - A variadic function is a function that accepts a variable number of arguments. It uses the <stdarg.h> header and the va_list type.

28. Discuss the use of malloc() and free() functions in C. - malloc() is used to dynamically allocate memory, and free() is used to release allocated memory.

29. How do you declare a function that returns a pointer in C? - The function declaration specifies the return type as a pointer type (e.g., int*).

30. What is a callback function in C? - A callback function is a function passed as an argument to another function. It allows for dynamic behavior and customization.

31. Explain the purpose of the volatile keyword in function parameters. - The volatile keyword indicates that the parameter value may change at any time, without any action being taken by the code the compiler finds nearby.

32. How can you implement a function that swaps the values of two variables? - Pass the addresses of the variables to a function, and use pointers to swap their values.

33. Discuss the role of the restrict keyword in function parameters. - The restrict keyword indicates that the function's parameters are not aliased, allowing for optimization.

34. What is the purpose of a function template in C++? - Function templates in C++ allow writing generic functions that can work with different types.

35. Explain the concept of function inlining. - Function inlining is a compiler optimization that replaces a function call with the actual code of the function to improve performance.

36. How is exception handling implemented in C++ functions? - C++ functions can use try, catch, and throw for exception handling.

37. Discuss the use of the auto keyword in C++ functions. - The auto keyword in C++ functions is used for automatic type inference, allowing the compiler to deduce the variable type.

38. What is a lambda function in C++? - A lambda function is an anonymous function defined using the lambda expression syntax ([]{}) in C++.

39. How can you pass a function as an argument to another function in C++? - Function pointers or std::function can be used to pass functions as arguments in C++.

40. Explain the concept of function overloading in C++. - Function overloading in C++ allows defining multiple functions with the same name but different parameter lists.

41. Discuss the use of the override keyword in C++ functions. - The override keyword in C++ functions is used to indicate that a derived class function is intended to override a base class function.

42. What is a virtual function in C++? - A virtual function in C++ is a function declared in a base class and overridden by a derived class.

43. Explain the purpose of the const keyword in a C++ function declaration. - The const keyword in a C++ function declaration indicates that the function does not modify the object it is called on.

44. How can you declare a pure virtual function in C++? - A pure virtual function in C++ is declared by appending = 0 to the function declaration in the base class.

45. What is the purpose of the friend keyword in C++ functions? - The friend keyword in C++ functions allows access to private or protected members of a class by another class or function.

46. How are functions defined in a C++ namespace? - Functions can be defined inside a C++ namespace to avoid naming conflicts.

47. Discuss the role of the decltype keyword in C++ functions. - The decltype keyword in C++ functions is used for type deduction, determining the type of an expression.

48. What is the purpose of the constexpr keyword in C++ functions? - The constexpr keyword in C++ functions indicates that the function can be evaluated at compile time.

49. How do you use the noexcept specifier in C++ functions? - The noexcept specifier in C++ functions indicates that the function does not throw exceptions.

50. Explain the concept of function templates in C++. - Function templates in C++ allow defining generic functions that can operate on different data types.

✍

Thanks for reading. Share this with a friend who is preparing too.

Comments

Want the complete course?Get full notes, tests and expert support.Browse Premium Courses
Simple & easy

How It Works

Get your notes in three easy steps.

1

Pick your exam

Choose UPSC, SSC, Banking, Railways, State PSC or Defence and find the subject you need.

2

Preview a free sample

Flip through sample pages with Quick Look before you decide to buy.

3

Buy and download the PDF

Pay securely and download your notes to read or print on any device.

FAQ

Frequently Asked Questions

How do I download the notes after buying?

After your payment is complete you receive a download link for the PDF. Open it on any device and save the file for offline reading.

Can I print the PDF notes?

Yes. The notes use a print-friendly layout with clean margins, so you can print the pages you need or the full notes.

How often are the notes updated?

Notes are reviewed for each exam cycle and pattern change. The latest status is shown on every product card, for example Updated Pattern.

Can I see a sample before I buy?

Yes. Every notes pack has a free sample. Click Free Sample (PDF) or Quick Look to flip through sample pages before you pay.

Which devices can I use to read the notes?

The notes are PDF files that open on mobiles, tablets, laptops and desktops with any free PDF reader.

Are the notes available in Hindi and English?

The language of each pack is shown on its card. Use the search box to find notes in the language you prefer.