A. 
#include<iostream.h>
#include<conio.h>
class demo
{
private:
                int x;
public:
                void read()
                                {
                                cout<<"Enter The Value of X : ";
                                cin>>x;
                                }
                void display()
                                {
                                cout<<"\nX = "<<x<<endl;
                                }
};
void main()
{
                demo d;
                clrscr();
                d.read();
                d.display();
                getch();
}
140-a
B. 
#include<iostream.h>
#include<conio.h>
class demo
{
private:
                int x;
public:
                void read()
                                {
                                cout<<"Enter The Value of X : ";
                                cin>>x;
                                display();
                                }
private:
                void display()
                                {
                                cout<<"\nX = "<<x<<endl;
                                }
};
void main()
{
                demo d;
                clrscr();
                d.read();
                getch();
}
140 B.PNG
Advertisements