Return Statement in C

The return statement in C is used to terminate the execution of a function and return a value to the caller. It is commonly used to provide a result back to the calling code.

return expression;

Example

C




#include <stdio.h>
  
int add(int a, int b)
{
    int sum = a + b;
    return sum; // Return the sum as the result of the
                // function
}
  
void printMessage()
{
    printf("w3wiki\n");
    return; // Return from the function with no value (void)
}
  
int main()
{
    int result = add(5, 3);
    printf("Result: %d\n", result);
  
    printMessage();
  
    return 0;
}


Output

Result: 8
w3wiki



Jump Statements in C

In C, jump statements are used to jump from one part of the code to another altering the normal flow of the program. They are used to transfer the program control to somewhere else in the program.

In this article, we will discuss the jump statements in C and how to use them.

Similar Reads

Types of Jump Statements in C

There are 4 types of jump statements in C:...

1. break in C

The break statement exits or terminates the loop or switch statement based on a certain condition, without executing the remaining code....

2. Continue in C

...

3. Goto Statement in C

The continue statement in C is used to skip the remaining code after the continue statement within a loop and jump to the next iteration of the loop. When the continue statement is encountered, the loop control immediately jumps to the next iteration, by skipping the lines of code written after it within the loop body....

4. Return Statement in C

...