Write a program to make the class using two numbers and use constructor in class and use avg function to take the average of numbers.

#include<iostream>

using namespace std;

class number

{

int X,y;

public:

number()    /* constructor , we will not call to constructor

it will call automaticaly*/

{

X=y=100;

}

int avg()

{

cout<<“x= “<<X<<endl;

cout<<“y= “<<y<<endl;

cout<<“Average= “<<(X+y)/2<<endl;

}

};

int main()

{

number n;

n.avg();  /*here we are calling to member function

(average) we have no need to call constructor */

system(“pause”);

 

}