In this type of function argument and parameter must be specified and function doesn't return any value so the datatype of function must be "void"
syntax:-
void function name(datatype arg 1,datatype arg 2)
{
statement;
.........
..........
}
example:-write a program to input 3 number and calculate sum using function with argument and no return.
Ex:-
void main()
{
int a,b,c;
void sum(int,int,int);
printf("\n enter three number");
scanf("%d%d%d",&a,&b,&c);
sum(a,b,c);
getch();
}
void sum(int x,int y,int z)
{
int add;
add=x+y+z;
printf("\n sum of three number=%d",add);
}
syntax:-
void function name(datatype arg 1,datatype arg 2)
{
statement;
.........
..........
}
example:-write a program to input 3 number and calculate sum using function with argument and no return.
Ex:-
void main()
{
int a,b,c;
void sum(int,int,int);
printf("\n enter three number");
scanf("%d%d%d",&a,&b,&c);
sum(a,b,c);
getch();
}
void sum(int x,int y,int z)
{
int add;
add=x+y+z;
printf("\n sum of three number=%d",add);
}
Comments
Post a Comment