Find us On Facebook

Thursday, April 7, 2011

Write a program to read two numbers from the keyboard and display the larger value on the screen.

#include<conio.h>
#include<iostream.h>

class largest
{
int d;
public :
void getdata(void);
void display_large(largest,largest);
};

void largest :: getdata(void)
{
cout<<"\n\nEnter Value :-";
cin>>d;
}

void largest :: display_large(largest o1,largest o2)
{
    if(o1.d > o2.d)
       cout<<"\nObject 1 contain Largest Value "<<o1.d;
   else if(o2.d > o1.d)
       cout<<"\nObject 2 contain Largest Value "<<o2.d;
   else
       cout<<"\nBOTH ARE EQUAL";
}


void main()
{
largest o1,o2,o3;
clrscr();

o1.getdata();
o2.getdata();

o3.display_large(o1,o2);
getch();
}

1 comments:

Anonymous said...

can sum 1 plzzz explain this code ?????????
plzzzz do it as soon as possible m a beginner so m having diff in understanding the functions GETDATA AND DISPLAY AND WHY WE HAVE USED THREE OBJECTS

Post a Comment

Programms

C,C++,VB, PL/SQL EBOOK SEARCH ENGINE