C Language



Admission Enquiry Form

  

Function with Argument and with no Return



Function with argument and with no return value in C

Function with argument and with no return means when calling function is giving some value to called function as an argument and called function is not returning any value to calling function.

Example:

#include<stdio.h>
#include<conio.h>
int num1,num2,res;//global variables
void main()
{
void sum(int,int); //declaration of function
printf("\nCalling sum fun");
printf("\nEnter two no's");
scanf("%d%d",&num1,&num2);
//here, num1 and num2 are actual arguments
sum(num1,num2); //call by value
printf("\nBye");
getch();
}//end of main

                 void sum(int n1,int n2)   //body of function
{
//here, n1 and n2 are formal arguments
res=n1+n2;
printf("\nResult is %d",res);
}


Output

Calling sum fun
Enter two no's100
200

Result is 300
Bye