Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*program to read and display 2 complex numbers*/
- #include<iostream.h>
- #include<conio.h>
- class complex //class declaration
- {
- private : float real;
- float imag;
- public : void read();
- void display();
- };
- void complex :: read()
- {
- cout<<"Enter value for real part: ";
- cin>>real;
- cout<<"Enter value for imaginary part: ";
- cin>>imag;
- }
- void complex :: display()
- {
- cout<<real<<"+"<<imag<<"i"<<endl;
- }
- int main()
- {
- complex r1,r2;
- clrscr();
- r1.read();
- r1.display();
- cout<<"\n";
- r2.read();
- r2.display();
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment