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
The procedure +, * and list take arbitrary numbers of arguments. One way to define such a procedure is to use define with dotted-tail notation. In a procedure definition, a paramet

A: Using the extern "C" linkage specification around the C function declarations. Programmers must know about mangled function names and type-safe linkages. After that they must

In this problem you are given a board in which some of the elements are placed as shown in diagram below. Each element represents a color. Fill the other elements in the board, suc

payment system, in c++ only..just use the printf or scanf.please

# 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

P r i va t e Member Functions: A private member functions can be called by the members of the same class.  Consider the following example.   c l a ss sample

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

What is Ms dos?

count the number of string in n-th padovan string

Task 1 Demonstrate a Java client and server exchanging one text message in each direction. Task 2 Demonstrate a C client and server exchanging one text message in each