Thursday, October 16, 2014

program to find maximum value from two values by using nesting of function in C++



Prog 21 :Write a program to find maximum value from two values by using nesting of function.
#include<iostream.h>
#include<conio.h>
class value
{

int a,b;
public:
void display();
int max();
};

int value::max()
{
cout<<"\n enter a and b";
cin>>a>>b;
if(a>b)

return a;
else
return b;
}

void value::display()
{
cout<<"\n max value is"<<max();
}
void main()
{
clrscr();
value v1;
v1.display();
getch();
}
Output:
enter a and b
10
20
max value is20

No comments: