Tuesday, 16 December 2014

C++ TO FIND LARGEST OF TWO NUMBER USING NESTING MEMBER FUNCTION

 Write a program to input two numbers and find the largest of them using nesting member function.


#include<iostream.h>
#include<conio.h>
class set
{
int a,b;
 public:
void input(void);
void display(void);
int largest(void);
};
int set :: largest(void)
{
if(a>=b)
return (a);
else
return(b);
}
void set :: input(void)
{
cout<<"Input values of a and b:" << "\n";
cin >> a >>b;
}
void set :: display(void)
{
cout<<"Largest value ="<< largest( ) << "\n";
}
main( )
{
set A;
A.input( );
A.display( );
getch( );
return 0;
}

OUTPUT:
Input values of a and b:
3 4
Largest value= 4

3 comments:

  1. This is nice blog. The information you provide is remarkable. For more information on this topic, visit here Nesting of Member Functions – Object Oriented Programming (OOP)

    ReplyDelete
  2. can you please provide me answer of this question - using the concept of nesting of member function find the largest of any three numbers.

    ReplyDelete
  3. nyc...i want more information and programs on nesting of member functon....

    ReplyDelete