Pages

Monday, October 10, 2011

FUNCTIONS_3

WAP TO PRINT THE LARGEST OF THE 2 NUMBERS USING (?:) CONDITIONAL OPERATOR

#include<iostream.h>
#include<conio.h>
class comparison
{
int x,y,max;
public:
void get();
void largest();
void print();
};
void comparison::get()
{
cout<<"Enter value of x & y::";
cin>>x>>y;
}
void comparison::largest()
{
max=(x>y)?x:y;
}
void comparison::print()
{
cout<<"x="<<x<<endl<<"y="<<y<<endl
    <<"max="<<max ;
}
void main()
{
clrscr();
comparison c;
c.get();
c.largest();
c.print();
getch();
}

No comments: