Define a complex number in c program, C/C++ Programming

Assignment Help:

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();

       }


Related Discussions:- Define a complex number in c program

Pseudocode , Record separation problem Let us assume that a particular data...

Record separation problem Let us assume that a particular database program manages a simple mailing list which consists of one record for each person on the list, and a number of f

Calculate the area and circumference of a circle , Write a program which in...

Write a program which incorporates a function named compute and which is used to calculate the area and circumference of a circle. Use the main function for inputs and outputs.

Explain the type conversion in expressions in c language, Explain The Type ...

Explain The Type Conversion in Expressions in c language? When variables and constants of different types are used in an expression they are all converted to same type. The com

Example of function - c program, Here is a short program. It prints out the...

Here is a short program. It prints out the value of a variable "x". Ernie and Bert disagree about what will be printed: Ernie says, the value gets changed in "changeX" so it will p

What is difference among macro and template?, A: In C++ there is a main dif...

A: In C++ there is a main difference among a template and a macro. Merely a macro is a string which the compiler replaces along with the value that was defined. For example #define

Define the char data type of c language, Define the Char Data Type of C Lan...

Define the Char Data Type of C Language? The char defines characters. The char type will usually require only 1 byte of internal storage. Every char type has an equivalent inte

Luminous jewels polishing necklace, 1.jewels can only be removed for polish...

1.jewels can only be removed for polishing from either end of the necklace. 2.cost of polishing=sitting number*colour value of jewels.

Restart, how to create program in c that will system restart

how to create program in c that will system restart

Destructor, Destructor: The purpose of destructor is to free the memory...

Destructor: The purpose of destructor is to free the memory when the compiler memory is reduced or not enough to execute certain program. Sometimes there may several objects op

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd