Thursday, February 4, 2021

Program to Moderate the values of Two variables in C++

Moderate the values of Two variables (in C++)



#include<iostream.h>
#include<conio.h>
class demo
{
  private:
int x,y;
public:
int a,b;
void getdata();
void putdata();
};
void demo::getdata()
{
cout<<"Enter the values of x & y\n";
cin>>x>>y;
cout<<"Enter the value of a & b\n";
cin>>a>>b;
}
void demo::put data()
{
cout<<"the values of x & y are";
cout<<x<<y;
cout<<"The values of a & b are";
cout<<a<<b;
}
void main()
{
clrscr();
demo.d;
d.getdata();
d.putdata();
d.a=20;
d.b=30;
cout<<"the value after moderation:";
d.putdata();
getch();
}



Output :


Enter the value of x & y
30
20
Enter the value of a & b
20
30
The value of x & y are 
30 20 The value of a & b are 
20 30 The value after moderate value 
30 20 The value of a & b are 

No comments:

Post a Comment