PROGRAM TO FIND LARGEST OF TWO NUMBERS USING CLASS AND NESTING THE FUNCTION
/*WRITE A PROGRAM TO FIND LARGEST OF TWO NUMBERS USING CLASS AND NESTING THE FUNCTION*/
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class large
{
int a, b;
public:
void getdata()
{
cout<<"enter two numbers";
cin>>a>>b;
}
void largest()
{
if(a>b)
cout<<"largest number="<<a;
else
cout<<"largest number="<<b;
}
void putdata()
{
largest();
}
};
void main()
{
large obj;
obj.getdata();
obj.putdata();
}
----------------------------------------------------------
OUTPUT:-
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class large
{
int a, b;
public:
void getdata()
{
cout<<"enter two numbers";
cin>>a>>b;
}
void largest()
{
if(a>b)
cout<<"largest number="<<a;
else
cout<<"largest number="<<b;
}
void putdata()
{
largest();
}
};
void main()
{
large obj;
obj.getdata();
obj.putdata();
}
----------------------------------------------------------
OUTPUT:-
0 comments