Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

4bh1n4v
Copy link

@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.

None yet

1 participant