Pages

January 22, 2013

Function with parameters with no return


syntax of function with argument with no return type in C language

Function can also use parameters and these parameters should be specified as a list along with function name with specific data types and each argument should be separated by ‘,’.
In function with parameter or arguments two types of arguments are used ACTUAL PARAMETERS and FORMAL OR DUMMY PARAMETERS.


Actual parameters are used when function called in any other function or main function but formal parameters are used when function is defined it means passing by value will take place between actual and formal parameters. 
Both these parameters are local parameters and corresponding actual parameters can transfer values to corresponding formal parameters. 

/*Program to enter values by user and observe the function */


#include<stdio.h>
#include<conio.h>
void sum(int x,int y)
{

     int add;
     add=x+y;
     printf("\n addition of two numbers is %d",add);
     }
void main()
{
     int a,b;
     printf("\n enter any value of a and b");
     scanf("%d%d",&a,&b);
     sum(a,b);
     getch();
     }
output of function with parameters with no return type of addition in C language

No comments:

Post a Comment