In this type of function,parameter and argument are not passed to any f\unction and function must return a value.So the datatype of function depends up on the datatype of return value of the function.
syntax:-
datatype function name()
{
statement;
..........
................
return(exp);
}
* Ex:-
void main()
{
int x;
int sum();
x=sum();
printf("\n sum=%d",x);
getch();
}
int sum()
{
int a,b,c;
printf("\n enter two number");
scanf("%d%d",&a,&b);
c=a+b;
return(c);
}
syntax:-
datatype function name()
{
statement;
..........
................
return(exp);
}
* Ex:-
void main()
{
int x;
int sum();
x=sum();
printf("\n sum=%d",x);
getch();
}
int sum()
{
int a,b,c;
printf("\n enter two number");
scanf("%d%d",&a,&b);
c=a+b;
return(c);
}
Thanks for this programming.
ReplyDeleteThanks for this programming.
ReplyDelete