Skip to content

I faced this question during my oops labs, maybe you could add this t…#2

Open
4bh1n4v wants to merge 1 commit intonickedes:masterfrom
4bh1n4v:master
Open

I faced this question during my oops labs, maybe you could add this t…#2
4bh1n4v wants to merge 1 commit intonickedes:masterfrom
4bh1n4v:master

Conversation

@4bh1n4v
Copy link
Copy Markdown

@4bh1n4v 4bh1n4v commented Sep 30, 2020

…o prac folder so if anybody else needs it might be helpful

A complex number x + iy is a number which has 2 parts - a real part (x) and an imaginary part (y). Write a C++ program that simulates a complex number as an object. Assume both x and y are integers. The user should be able to do the following operations on these complex number objects:
a) Addition of 2 complex numbers by writing the code: c3 = c1+c2

b) Multiplying c1 and c2 and storing the result in c1 using the code: c1 *= c2

c) Overload a type casting operator that allows implicit / explicit type casting of a complex number object to a float variable as follows:

float x;
x=c1; // where c1 is a complex number object

For example,
i) If c1 = 10+6i, then x will store 10.6
ii) If c1 = 5+22i, then x will store 5.22

…o prac folder so if anybody else needs it might be helpful

A complex number x + iy is a number which has 2 parts - a real part (x) and an imaginary part (y). Write a C++ program that simulates a complex number as an object. Assume both x and y are integers. The user should be able to do the following operations on these complex number objects:
a) Addition of 2 complex numbers by writing the code: c3 = c1+c2

b) Multiplying c1 and c2 and storing the result in c1 using the code: c1 *= c2

c) Overload a type casting operator that allows implicit / explicit type casting of a complex number object to a float variable as follows:

float x;
x=c1; // where c1 is a complex number object

For example,
i) If c1 = 10+6i, then x will store 10.6
ii) If c1 = 5+22i, then x will store 5.22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant