Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Programming: Write a complete program that accomplishes the following tasks: Display a friendly greeting to the user Prompt the user for a complex number;

C++ Programming:

Write a complete program that accomplishes the following tasks:

Display a friendly greeting to the user

Prompt the user for a complex number; call it a.

Accept that complex number using cin.

Display that complex number using cout.

Prompt the user for a complex number; call it b.

Accept that complex number using cin.

Display that complex number using cout.

Display a line of code that states whether or not a is the same as b, using ==

Display a line of code that states whether or not a is different from b, using !=

Create a new complex number; call it c.

Make c the sum of a and b, using c = a + b

Display the result using cout

Add a to c using c += a

Display the result using cout

Subtract b from c using c -= b

Display the result using cout

Make c the difference of a and b, using c = a b

Display the result using cout

Make c the product of a and b, using c = a * b (see note below)

Display the result.

Create complex numbers x, y, and z, and display the results of x = y = z = c

Display a double type-cast to a ComplexNumber.

Display a ComplexNumber type-cast to a double.

The product of two complex numbers is found as follows:

if a = ar + ai i and b = br + bi i then

the real part of a * b = ar * br ai * bi

and the imaginary part of a * b = ar * bi + ai * br

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions