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

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

       }

Posted Date: 10/18/2012 6:36:53 AM | Location : United States







Related Discussions:- Define a complex number in c program, Assignment Help, Ask Question on Define a complex number in c program, Get Answer, Expert's Help, Define a complex number in c program Discussions

Write discussion on Define a complex number in c program
Your posts are moderated
Related Questions
write a class player that contain attributes for the player,s name,average and team

At a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets with thes

A Padovan string P(n) for a natural number n is defined as: P(0) = ‘X’ P(1) = ‘Y’ P(2) = ‘Z’ P(n) = P(n-2) + P(n-3), n>2 where + denotes string concatenation. For a string of t

write a c++ program for minimum shelf downloads

Can you think of a condition where your program would crash without attaining the breakpoint that you set at the starting of main()? A: C++ let for dynamic initialization of glo

1. Create text a file with the name "myemail" that has a single line in it, consisting of your email address. Something like "firstname_lastname@carleton.ca" (or your hotmail or gm

Write a program consisting of two functions (plus main). The first function should read in a number and then pass this back to main. This value should then be passed into a secon

# include stdio.h> # include string.h> # include conio.h> void main() {           int i=0,j=0,b=0,count=0;           int a[100];           for(i=0;i

Write a C program to compute the value of a sine wave from 0 to 2P with an increment of 0.1 radians.   #include stdio.h #include math.h #define pi 3.1415927 void main() {   c

when a class is defined the compiler will not allocate memory. This is true only for data member not for member function.  As soon as the member function is defined  the require