Program to create a class name max with 3 integer datatype members, first function store the inputs, second function to display the greatest between the 3 - TechnoHindi.Org

Latest

Thursday, August 6, 2020

Program to create a class name max with 3 integer datatype members, first function store the inputs, second function to display the greatest between the 3




#include <iostream.h> 
#include <conio.h> 
class max 
public: 
int a, b, c; 

void data (void) 
cout<<"Enter the 3 integer values: "<<endl; 
cin>>a>>b>>c; 

void display_data (void) 
if ( a>b && a>c ) 
cout<<"The greatest value is: "<<a; 

else if ( b>a && b>c ) 
cout<<"The greatest value is: "<<b; 

else if ( c>a && c>b ) 
cout<<"The greatest value is: "<<c; 

else 
cout<<"Error!"; 
}; 

void main() 
clrscr(); 
max x; 
x.data (); 
x.display_data (); 
getch(); 
}
  1. Output :-

No comments:

Post a Comment