BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan

BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan (http://bzupages.com/)
-   Object Oriented Programming (http://bzupages.com/35-object-oriented-programming/)
-   -   Help me:for Assignment.Program which use arithmatic Operations on Complex Numbers (http://bzupages.com/f35/help-me-assignment-program-use-arithmatic-operations-complex-numbers-1599/)

sohail 18-12-2008 02:15 PM

Help me:for Assignment.Program which use arithmatic Operations on Complex Numbers
 
mujy complex number ka pro chaiy pro that perform multiplication ,addtion substraction , divsion so please hlpe me in my assingment of oop

BSIT07-01 18-12-2008 02:39 PM

Re: complex numbers that perform multipilacation ,division, addition ,substraction c+
 
1 Attachment(s)
Code:

/*The Given Program performs Basic Arithematic operation : Addition, Subtraction, Multiplication and Division for Two Complex Numbers. */

#include< iostream.h>
#include< conio.h>
#include< process.h>
class complex
{
float real;
float imag;
public:
complex()
{}
complex(float x,float y)
{
real=x;
imag=y;
}
complex operator + (complex);
complex operator - (complex);
complex operator * (complex);
complex operator / (complex);
void display(void)
{
cout< < real< < " +i" < < i mag< < endl;
}

};

complex complex :: operator +(complex c)
{
complex c2;
c2.real=real+c.real;
c2.imag=imag+c.imag;
return (c2);
}

complex complex :: operator -(complex c)
{
complex c2;
c2.real=real-c.real;
c2.imag=imag-c.imag;
return (c2);
}
complex complex :: operator *(complex c)
{
complex c2;
c2.real = ((real * c.real) - (imag * c.imag));
c2.imag = ((real * c.imag) + (imag * c.imag));
return (c2);
}
complex complex :: operator /(complex c)
{
complex c2;
c2.real=((real * c.real) + (imag * c.imag))/((real * c.real) + (imag * c.imag));
c2.imag=((imag * c.real) - (real * c.imag))/((real * c.real) + (imag * c.imag));
return (c2);
}

void main()
{
clrscr();
complex c1,c2,c3;
int op;
char ch,y,Y;

c1 = complex(5.6,2.7);
c2 = complex(3.5,5.6);
cout< < "Two Complex numbers Are :"< < endl;
c1.display();
c2.display();
do
{
cout< < endl< < "******** MENU *********"< < endl;
cout< < "1. Addition\n2. Subtraction\n3. Multiplication\n4. Division\n5. Exit"< < endl;
cout< < "Enter Your Choice : ";
cin>>op;
switch(op)
{
case 1:
c3 = c1 + c2;
cout< < "Addition of Two complex Nos. :";
c3.display();
break;

case 2:
c3 = c1 - c2;
cout< < "Subtraction of Two complex Nos. :";
c3.display();
break;

case 3:
c3 = c1 * c2;
cout< <" Multiplication of Two complex Nos. :";
c3.display();
break;

case 4:
c3 = c1 / c2;
cout< < "division of Two complex Nos. :";
c3.display();
break;

case 5:exit(0);

default: cout< < endl< < "Aborting!!!!!!!INVALID CHOICE"< < endl;
}
cout< < " Do you want to continue(Y/y)";
cin>>ch;
}
while(ch=='y'||ch=='Y');
getch();
}
/******************* OUTPUT ********************
Two Complex numbers Are :
5.6 +i2.7
3.5 +i5.6

******** MENU *********
1. Addition
2. Subtraction
3. Multiplication
4. Division
5. Exit
Enter Your Choice : 1
Addition of Two complex Nos. :9.1 +i8.3
Do you want to continue(Y/y)y

******** MENU *********
1. Addition
2. Subtraction
3. Multiplication
4. Division
5. Exit
Enter Your Choice : 2
Subtraction of Two complex Nos. :2.1 +i-2.9
Do you want to continue(Y/y)y

******** MENU *********
1. Addition
2. Subtraction
3. Multiplication
4. Division
5. Exit
Enter Your Choice : 3
Multiplication of Two complex Nos. :4.48 +i46.48
Do you want to continue(Y/y)y

******** MENU *********
1. Addition
2. Subtraction
3. Multiplication
4. Division
5. Exit
Enter Your Choice : 4
division of Two complex Nos. :1 +i-0.631048
Do you want to continue(Y/y)n
*/

Hello...
Dear I am busy in my exams...
Anyway I am sharing the above program for you...
With the output of the program which will help you to understand the Program..:waiting2:
You can download the attachment below

:waiting2:Dear Please introduce yourself in the introduction forum. because I know nothing about you.:scratchchin:

sohail 19-12-2008 11:55 AM

Re: Help me:for Assignment.Program which use arithmatic Operations on Complex Numbers
 
thank you brother you solve my big problem again very very.............. thankful


All times are GMT +5. The time now is 01:50 PM.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.