In this type of function arguments and parameters must be passed to any function and function return a single value.The type of function depends up on the return value.
syntax:-
datatype of function name(datatype arg 1,datatype arg2)
{
statement;
...........
...........
return(exp);
}
ex:-main()
{
int fact(int);
printf("\n factorial =%d",fact(5));
getch();
}
int fact(int n)
{
int f=1;
while(n>1)
{
f=f*n;
n--;
}
return(f);
}
syntax:-
datatype of function name(datatype arg 1,datatype arg2)
{
statement;
...........
...........
return(exp);
}
ex:-main()
{
int fact(int);
printf("\n factorial =%d",fact(5));
getch();
}
int fact(int n)
{
int f=1;
while(n>1)
{
f=f*n;
n--;
}
return(f);
}
Comments
Post a Comment