I faced this question during my oops labs, maybe you could add this t…#2
Open
4bh1n4v wants to merge 1 commit intonickedes:masterfrom
Open
I faced this question during my oops labs, maybe you could add this t…#24bh1n4v wants to merge 1 commit intonickedes:masterfrom
4bh1n4v wants to merge 1 commit intonickedes:masterfrom
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…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