LearnFrenzy
Sign in Take a free test

C Programming · Topic 4 of 23

Functions

  • 4 exercises
  • 40 questions
  • ~60 min
  • Answers explained

Interview Questions

Functions · Study material

C Functions Interview Questions and Answers

1. What is the difference between call by value and call by reference in C?

C only has call by value: the function gets copies of the arguments. Call by reference is simulated by passing pointers, so the function can change the caller's variables.

2. What is a function prototype, and why is it needed?

A declaration of the return type and parameter types. It lets the compiler check each call and convert arguments correctly. Since C99, calling an undeclared function is not allowed.

3. What does static mean for a local variable and for a function?

For a local variable: one instance with static storage duration, initialised once and kept between calls. For a function: internal linkage – it can only be called from its own source file.

4. What is recursion? What is a base case?

A function that calls itself on a smaller input. The base case is the input it answers directly, without recursing; without one, the recursion never stops.

5. What is the difference between int f() and int f(void)?

Before C23, int f() meant "unspecified parameters" and calls were not checked. In C23 both mean "no parameters".

6. Is the order of evaluation of function arguments defined?

No, it is unspecified. In printf("%d %d", next(), next()) either call may run first.

7. Can a function return an array?

No. It can return a pointer (to static or heap memory, never to a local array) or a struct that contains an array.

8. What is a function pointer used for?

Callbacks (qsort() comparators, event handlers), tables of operations, and choosing behaviour at run time.

9. What is the difference between inline and a macro?

An inline function is a real, type-checked function the compiler may expand in place; a macro is text substitution with no type checking and surprises with side effects such as MAX(i++, j).

10. What is a variadic function?

One that takes a variable number of arguments, declared with ... and read with va_start, va_arg and va_end from <stdarg.h>.

11. What does [[noreturn]] (or _Noreturn) mean?

The function never returns to its caller, like a wrapper around exit() or abort(). The compiler can optimise and warn accordingly.

12. What does [[nodiscard]] do in C23?

It asks the compiler to warn when a caller ignores the function's return value – useful for error codes and allocated memory.

Ready to test your Programming?

Timed online tests with instant scores and explanations.

About this section

About C Programming

C programming is the language most computer science courses start with and the foundation of operating systems, embedded devices and compilers. This section helps you learn C properly – data types, operators, control statements, functions, arrays, strings, pointers, structures, memory allocation and files – and then prove it with hundreds of practice questions explained line by line.

Why it matters

  • C teaches how a computer really works: memory, addresses and how data is stored
  • Pointers and memory questions are a favourite in written tests and technical interviews
  • Once you know C, learning C++, Java and Python becomes much easier
  • Embedded systems, operating systems and many companies' coding rounds still use C

Who it is for

  • School students (Class 11–12 computer science) building a strong programming base
  • College students (B.Tech, BCA, MCA, B.Sc CS) preparing for semester exams, lab work and viva
  • Freshers preparing for campus placements, aptitude-cum-coding tests and technical interviews
  • Anyone preparing for GATE CS or government IT exams

What every topic gives you

  • Study material in five tabs: concepts with runnable examples, coding techniques, programs, interview questions and a cheat sheet
  • MCQs that check your understanding of every concept
  • "Predict the output" puzzles – the trickiest part of written tests
  • "Find the error" programs that train you to spot bugs quickly
  • Complete programs with solutions and real output, verified on a compiler

Asked in

  • Campus placements
  • TCS, Infosys, Wipro tests
  • Technical interviews
  • GATE CS
  • University exams
  • Government IT exams

How to use this section

  1. Read the study material of a topic and run the examples yourself.
  2. Practise the four exercises – MCQs, output, errors, programs – and read every explanation.
  3. Test yourself with the timed online test, then revise the topics you got wrong.

Search LearnFrenzy

Esc

Quick links