define a complex number in c programclass


Define a complex number in c program:

class complex

                                {

 

                                private:

                                int real,ima;

 

                                public :

                                void input();

                                friend complex sum(complex,complex);

                                void show();

                                };

 

 void complex:: show(void)

                {

                 cout << "real part ="<< real << "\nThe imaginary part ="<

                 }

 

 void  complex ::input()

                {

                cout<<"enter the real and imaginary part\n";

                cin >> real >> ima;

                }

 

complex sum( complex a,complex b)

                {

                complex c;

                c.real= a.real + b.real;

                c.ima= a.ima + b.ima;

                return c;

                }

 

void main()

                {

                complex a,b,c;

                clrscr();

                a.input();

                b.input();

                c=sum(a,b);

                c.show();

                getch();

       }

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: define a complex number in c programclass
Reference No:- TGS0174768

Expected delivery within 24 Hours