Write a program in C++ to find the max using class
#include<iostream.h>
class max { private : int x,y; public : setvalue(int m,int n) { x=m; y=n; } void display() { int max; max=larger(); if(max!='@') { cout << "maximum is : "<<max; } else { cout << "both the nos are equal"<<endl; } } int larger() { if(x>y) { return x; } else if(y>x) { return y; } else { return '@'; } } }; void main() { int a,b; max o1; cout << "enter two values to find out the maximum"<<endl; cin >>a>>b; o1.setvalue(a,b); o1.display(); } |