Functions in C: 12 Solved MCQs on Declarations, Definitions and Function Types

Separate a C function's prototype, body and call, then practise the details through 12 explained questions covering parameters, return values and linking.

KnowledgeGate Team

Exam prep & CS education

Updated 14 Aug 20268 min read

You may be able to write a small C function and still hesitate when a question asks whether a line is its prototype, definition or call. The four common function types are also easy to memorise without seeing how their inputs and outputs actually change. Placement and teaching-recruitment papers push on exactly those two gaps: a one-line declaration to classify, or a five-line snippet whose printed output you have to predict. Fix the three roles below in your head first, then take the twelve questions in order. More practice on the same subtopic sits in the C functions PYQ module.

Functions in C: prototype, definition, call and the four types

int add(int a, int b); is a declaration or prototype. int add(int a, int b) { return a + b; } is the definition, and result = add(7, 5); is a call.

At the call, the formal parameters receive a = 7 and b = 5. The expression computes 7 + 5 = 12, then 12 returns to result.

Parameters

Return value

Example with 7 and 5

Result

None

None

void showFixedSum(void) sets local a = 7, b = 5

Prints 12

None

Present

int fixedSum(void) returns 7 + 5

Returns 12

Present

None

showSum(7, 5) calls void showSum(int a, int b)

Prints 12

Present

Present

result = add(7, 5) calls int add(int a, int b)

Returns 12

The two-by-two split above classifies user-defined functions by parameters and return value. Library versus user-defined is a separate axis: printf ships with the standard library, while add is one you write and must declare before you call it.

Function prototypes and declarations in C: Questions 1-4

Question 1 (TPSC 2024)

What is a function prototype used for ?

  • A. To define the return type of a function

  • B. To declare the function before its definition

  • C. To specify the function's parameters

  • D. To document the function's purpose

Answer: B. To declare the function before its definition.

The declaration lets the compiler check a call before the function body appears. A prototype includes return type and parameter information, so A and C describe pieces of it, not its best overall purpose here.

Practise this question

Question 2 (Hexaware 2025 / CoCubes 2025)

What is a function prototype in C?

  • A. A function that is used to create objects.

  • B. A complete function definition.

  • C. A declaration of a function that includes its signature but not its body.

  • D. The first function that is called in a C program.

Answer: C. A declaration of a function that includes its signature but not its body.

int add(int, int); declares the contract without a body. int add(int a, int b) { return a + b; } defines the function by adding executable statements.

Question 3 (Hexaware 2025 / CoCubes 2025)

What is the correct way to declare a function in C?

  • A. function myFunction(int x)

  • B. int function myFunction(int x)

  • C. int myFunction(int x);

  • D. declare myFunction(int x)

Answer: C. int myFunction(int x);

Read it left to right: int is the return type, myFunction is the name and int x declares the parameter. The semicolon ends the prototype, while the other options add words that are not C declaration syntax.

Question 4 (Hexaware 2023 / CoCubes 2023)

In C, which of the following is the correct function prototype for a function that takes no arguments and returns nothing?

  • A. void myFunction()

  • B. function myFunction(void)

  • C. void myFunction(void)

  • D. None of the above

Answer: C. void myFunction(void).

The first void says no value is returned, while parameter-list void explicitly says no arguments are accepted. Written as a complete declaration, it is void myFunction(void);.

Function signatures and return values in C: Questions 5-7

Question 5 (Hexaware 2023 / CoCubes 2023)

Which of the following is a valid function signature in C?

  • A. void myFunction(void);

  • B. void myFunction();

  • C. Both A and B

  • D. Neither A nor B

Answer: C. Both A and B.

Both forms are accepted C declarations, so the correct option has to cover both. Prefer void myFunction(void); when the contract is explicitly no arguments: in C17 and earlier, void myFunction(); declares a function whose parameter list is simply unspecified, so the compiler cannot check the call against it.

Question 6 (Hexaware 2024 / CoCubes 2024)

What is the return type of a function that does not return a value?

  • A. int

  • B. void

  • C. char

  • D. float

Answer: B. void.

A void return type says the function does its work without producing a value for the caller. showSum(7, 5) can print 12, but because void showSum(int a, int b) returns nothing, its call cannot be assigned to an int result.

Question 7 (UPLT 2026)

The value obtained in the function is given back to main by using __________ keyword.

  • A. Static

  • B. Return

  • C. New

  • D. Volatile

Answer: B. Return.

In C source code the keyword is lowercase return, as in return a + b;. With a = 7 and b = 5, the expression becomes return 12;, and the caller receives that value.

Practise this question

Function definitions and call execution in C: Questions 8-9

Question 8 (Hexaware 2023 / CoCubes 2023)

What will be the output of the following code snippet?

int add(int x, int y)
{
return x + y;
}
int main()
{
printf("%d", add(3, 5));
return 0;
}
  • A. 8

  • B. 3

  • C. 5

  • D. Compilation error

Answer: A. 8.

The definition gives add a body, and the call supplies actual arguments 3 and 5. Inside the function, formal parameters become x = 3 and y = 5, so x + y = 3 + 5 = 8; the returned integer is nested inside printf, which prints 8. The snippet leaves out #include <stdio.h>, so add that line before you compile it yourself.

Question 9 (CoCubes 2025)

Consider the following code snippet:

#include <stdio.h>
void myFunction(int x);
int main()
{
    myFunction(10);
    return 0;
}
void myFunction(int x)
{
    printf("%d", x);
}

What will be the output of the code?

  • A. 10

  • B. 0

  • C. Compilation error

  • D. Undefined behavior

Answer: A. 10.

The prototype void myFunction(int x); appears before main, while the definition follows it. At the call, actual argument 10 becomes formal parameter x = 10, and the function prints 10.

Parameter passing and function linkage in C: Questions 10-12

Question 10 (Beltron Programmer 2025)

What happens when a variable is passed by value to a function in C?

  • A. The function receives a copy of the variable's value

  • B. The function alters the original variable directly

  • C. The function accesses the memory location of the variable

  • D. The function gets a reference to the original variable

Answer: A. The function receives a copy of the variable's value.

If int n = 7; is passed to void change(int x) { x = 20; }, the callee's separate parameter x changes from 7 to 20, but the caller's object n remains 7. A pointer can be passed to reach another object, but C still passes the pointer value itself by value.

Practise this question

Question 11 (Coal India 2017)

The default storage class for functions in ‘C’ language is:

  • A. Static

  • B. Register

  • C. Extern

  • D. Auto

Answer: C. Extern.

A file-scope function declared without static has external linkage by default, so another translation unit can refer to it through a compatible declaration. static restricts it to its own translation unit; auto and register are not function storage classes.

Practise this question

Question 12

Consider a C program which has two components (modules), C1 and C2 defined in two different files. C1 has a reference to a function which is defined in C2. Consider the following statements with reference to the above scenario.

S1: While compiling the program both modules are compiled independently.

S2: The reference of function is resolved at link time.

Select the correct option:

  • A. Both S1 and S2 are true

  • B. S1 is true and S2 is false.

  • C. S1 is false and S2 is true.

  • D. Both S1 and S2 are false.

Answer: A. Both S1 and S2 are true.

main.c can compile with the declaration int add(int, int);, while math.c separately compiles the definition of add. The linker resolves the reference from main.o to the symbol supplied by math.o; it does not copy the function body into main.c.

Functions in C MCQ traps to review after the set

Trap

What the wrong option assumes

Correction

Prototype versus definition

A declaration already contains executable code

int add(int, int); declares; the braced body defines

void f(void) versus void f()

Both always express exactly the same parameter contract

Use void f(void) to state explicitly that there are no parameters

Pass-by-value versus direct mutation

Changing x inside change must change n

x is a copy; after x = 20, n remains 7

Compile time versus link time

Each compiler invocation must see every body

Each file compiles independently; the linker resolves external symbols

Putting it end to end: main.c declares int add(int, int); and calls add(7, 5), while math.c defines add. The two files compile independently to main.o and math.o. The linker connects the call in main.o to the definition supplied by math.o, and at run time that call evaluates to 12.

Functions in C MCQ revision: the short version and next step

Missed one? Go back by theme: declaration syntax and prototypes in Questions 1 to 5, return contracts in 6 and 7, call tracing in 8 and 9, parameter passing in 10, external linkage in 11 and 12. Before you retry a question, write its declaration, definition and call on three separate lines; most wrong answers in this set come from reading one of the three as another.

  • A prototype declares the contract.

  • A definition adds the body.

  • A call supplies actual arguments.

  • C passes arguments by value.

  • The four common user-defined-function types combine parameters present or absent with return value present or absent.

The C Language Course: Concepts, MCQs & Coding is the structured next step when you want concepts and practice together. The Coding & DSA Courses for Placements category lists the broader alternatives. Once function mechanics are clear and you want to judge the cost of loops and recursive calls, continue with Time Complexity: Big-O, Theta, Omega & Master Theorem.