Functions 329
OUTPUT:
Enter Date dd/mm/yy: 12 12 2001
Today = 12/12/2001
Tomorrow = 13/12/2001
Explanation In the above program three values date, month, and year are passed to function
dat (). The function displays date. The function dat () returns next date. The next date is printed
in function main (). Here, function d at () receives arguments and return values.
10.12 Write a program to send values to a user-defined function and receive and display the
return value.
#in clu de< std io.h>
#include<conio.h>
mainO
{
in t sum (in t , in t, in t), a ,b ,c ,s ;
c lrs c r ();
printf ("Enter Three Numbers :");
scanf ("%d %d %d", &a,&b,&c);
s=sum(a,b,c);
printf ("Sum = %d*'',s);
return 0;
}
$um( int x, int y, int z)
I
return (x+y+z);
I
OUTPUT:
Enter Three Numbers: 7 5 4
Sum = 16
Explanation In the above program the function sum () receives three values from function main ().
The sum () calculates the sum of three numbers and returns them to main ().
D) Without arguments but with return values
Table 10.6 Function without arguments but with return values
m ain()
abc()
{
{
int z;
Argument(s) are passed.
int y=5;
z=abc( );
Values are sent back.
}
return(y);
}