DESCRIPTION-:Function with parameters and with return value contains a parameters in the "function call" and return the value in the function definition.The value returned in the function definition is the final result or the output of the program.
Here in below we have a program which calculate the sum of two numbers by passing parameters in the function call and returning value in the function defination as output.
PROGRAM-:
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c;
int max(int,int);
cout<<"enter two numbers";
cin>>a>>b;
c=max(a,b);
cout<<"greatest number is"<<c;
getch();
}
int max(int x,int y)
{
if(x>y)
return(x);
else
return(y);
}
Here in below we have a program which calculate the sum of two numbers by passing parameters in the function call and returning value in the function defination as output.
PROGRAM-:
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c;
int max(int,int);
cout<<"enter two numbers";
cin>>a>>b;
c=max(a,b);
cout<<"greatest number is"<<c;
getch();
}
int max(int x,int y)
{
if(x>y)
return(x);
else
return(y);
}
0 comments:
Post a Comment