Return Without Argument Function in C


In C programming, a function that does not take any arguments but returns a value is called a non-void function. The syntax for defining a non-void function is as follows

        Syntax :
           return_type function_name ( ) // Function Definition
           {
                 // body of Statement ;
                  return value;
           }

  • Here, the return_type specifies the data type of the value that the function will return. The function_name is the name of the function and the value is the value that the function returns.
  • A non-void function can be called in the same way as other functions, by simply using the function name followed by empty parentheses:

                 result = function_name();

  • The value returned by the function is stored in the variable result.

Source Code

//Return Without Argument Function in C
#include<stdio.h>
 
int add();
 
int main()
{
    int a;
    a=add();
    printf("\nTotal : %d",a);
    return 0;
}
 
int add()
{
    int a,b;
    printf("\nEnter The Value of A & B : ");
    scanf("%d%d",&a,&b);
    return a+b;
}
 
To download raw file Click Here

Output

Enter The Value of A & B : 6
45

Total : 51

List of Programs


Sample Programs


Switch Case in C


Conditional Operators in C


Goto Statement in C


While Loop Example Programs


Looping Statements in C

For Loop Example Programs


Array Examples in C

One Dimensional Array


Two Dimensional Array in C


String Example Programs in C


Functions Example Programs in C