Return Statement in C (original) (raw)

Last Updated : 10 Jun, 2026

The return statement in C is used to terminate a function and transfer control back to the calling function. It can also return a value from the function to the caller.

**Syntax:

return return_value;

**Example:

int add()

{
return 10;
}

**Explanation: The function returns the value 10 to the calling function.

working of return statement

Working of Return Statement

Return Statement in Void Functions

A void function does not return any value. Therefore, using a return statement is optional.

**Syntax Without Return Statement:

void functionName()
{
// statements
}

C `

#include <stdio.h>

void display() { printf("Hello World"); }

`

**Explanation: The function executes normally and automatically ends after the last statement.

**Syntax With Return Statement:

void functionName()
{
return;
}

C `

#include <stdio.h>

void checkNumber(int num) { if(num < 0) return;

printf("Positive Number");

}

`

**Explanation: The function exits immediately when the number is negative.

Incorrect Use of Return in Void Function

A void function cannot return a value.

**Incorrect Syntax:

void display()
{
return 10;
}

C `

void display() { return 10; }

`

**Explanation: This causes a compilation error because a void function cannot return a value.

Return Statement in Functions Returning a Value

Functions with a non-void return type must return a value of the specified type.

**Syntax:

return expression;

C `

int square(int num) { return num * num; }

`

**Explanation: The function calculates and returns the square of the number.

Multiple Return Statements in a Function

A function can contain multiple return statements, but only one of them is executed during a function call.

**Syntax:

if(condition)
return value1;
return value2;

C `

int findSign(int num) { if(num > 0) return 1;

return -1;

}

`

**Explanation: The function returns 1 for positive numbers and -1 otherwise.

Returning Only One Value

The return statement can directly return only one value from a function.

**Syntax:

return value;

C `

int getAge() { return 25; }

`

**Explanation: The function returns a single integer value.

Common Mistakes

**1. Missing Return Statement:

int getNumber()
{
}

**Explanation: Non-void functions must return a value.

**2. Returning Wrong Data Type:

int getValue()
{
return "Hello";
}

**Explanation: A string cannot be returned from a function with return type int.

**3. Returning a Value from a Void Function:

void show()
{
return 100;
}

**Explanation: Void functions cannot return values.

return; Vs return value

Feature return; return value;
Used In Void Functions Non-Void Functions
Returns a Value No Yes
Terminates Function Yes Yes
Syntax return; return 10;
Example return; return num;