Your All-in-One AI-Powered Toolkit for Academic Success.

Available 24*7 on WhatsApp / Email

Unlock your academic potential

© 2024 | Zucol Services PVT LTD | All rights reserved.

Added on 2019/09/25

|14

|1822

|263

Report

AI Summary

The program is designed to perform various operations on complex numbers. The user can input the real and imaginary parts of two complex numbers and choose from eight different operations: addition, subtraction, multiplication, division, magnitude calculation in polar form, angle calculation in polar form, product in rectangular form, and division in rectangular form.

Your contribution can guide someone’s learning journey. Share your
documents today.

Report

To multiply two complex numbers I use the formula

Here, (xu – yv), the real part of the product, is the product of the real parts minus the

product of the imaginary parts, but (xv + yu), the imaginary part of the product, is the

sum of the two products of one real part and the other imaginary part.

I used the steps which are required to divide complex numbers:

Step 1: To divide complex numbers, you must multiply by the conjugate. To

find the conjugate of a complex number all you have to do is change the

sign between the two terms in the denominator.

Step 2: Distribute (or FOIL) in both the numerator and denominator to remove

the parenthesis.

Step 3: Simplify the powers of i, specifically remember that i2 = –1.

Step 4: Combine like terms in both the numerator and denominator, that is,

combine real numbers with real numbers and imaginary numbers with

imaginary numbers.

Step 5: Write you answer in the form a + bi.

I used the formula to divide two complex numbers :

In component notation with ,

To multiply two complex numbers I use the formula

Here, (xu – yv), the real part of the product, is the product of the real parts minus the

product of the imaginary parts, but (xv + yu), the imaginary part of the product, is the

sum of the two products of one real part and the other imaginary part.

I used the steps which are required to divide complex numbers:

Step 1: To divide complex numbers, you must multiply by the conjugate. To

find the conjugate of a complex number all you have to do is change the

sign between the two terms in the denominator.

Step 2: Distribute (or FOIL) in both the numerator and denominator to remove

the parenthesis.

Step 3: Simplify the powers of i, specifically remember that i2 = –1.

Step 4: Combine like terms in both the numerator and denominator, that is,

combine real numbers with real numbers and imaginary numbers with

imaginary numbers.

Step 5: Write you answer in the form a + bi.

I used the formula to divide two complex numbers :

In component notation with ,

Need help grading? Try our AI Grader for instant feedback on your assignments.

To convert rectangular form of complex number to polar form I used the formula

We have a + ib

Then polar form is sqrt(a*a + b*b) , atan(b/a)*180 / PI

In C PI is defined in math.h: #define PI 3.14159265358979323846

I use atan(), asin(), and acos(). Those are the respective inverses of tan, sin, and cos.

We have a + ib

Then polar form is sqrt(a*a + b*b) , atan(b/a)*180 / PI

In C PI is defined in math.h: #define PI 3.14159265358979323846

I use atan(), asin(), and acos(). Those are the respective inverses of tan, sin, and cos.

Code :

#include <stdio.h>

#include <stdlib.h>

#include <conio.h>

#include <math.h>

#define PI 3.14159265358979323846

int main()

{

printf("Welcome!\n");

int n;// choice of the user will be store in n

float a, b, c, d;

while(1) // This loop will run infinitely but it will break when user enter 9 to quit

{

printf("************************************************************************

******************************************\n");

printf("Menu\n");

printf("Please enter\n");

printf("1 to add two real numbers and display the result\n");

#include <stdio.h>

#include <stdlib.h>

#include <conio.h>

#include <math.h>

#define PI 3.14159265358979323846

int main()

{

printf("Welcome!\n");

int n;// choice of the user will be store in n

float a, b, c, d;

while(1) // This loop will run infinitely but it will break when user enter 9 to quit

{

printf("************************************************************************

******************************************\n");

printf("Menu\n");

printf("Please enter\n");

printf("1 to add two real numbers and display the result\n");

printf("2 to subtract two real numbers and display the result\n");

printf("3 to multiply two real numbers and display the result\n");

printf("4 to divide two real numbers and display the result\n");

printf("5 to add two complex numbers in the form a +- jb and c +- jd and display the

result in rectangular notation\n");

printf("6 to subtract two complex numbers in the form a +- jb and c +- jd and display the

result in rectangular notation\n");

printf("7 to multiply two complex numbers in the form a +- jb and c +- jd and display the

result in rectangular notation\n");

printf("8 to divide two complex numbers in the form a +- jb and c +- jd and display the

result in rectangular notation\n");

printf("9 to quit \n");

printf("Please enter your choice : ");

scanf("%d", &n);//n is used to store the choice of the user

if(n == 9) // if user enters 9 then break the loop and hence quit the program

printf("3 to multiply two real numbers and display the result\n");

printf("4 to divide two real numbers and display the result\n");

printf("5 to add two complex numbers in the form a +- jb and c +- jd and display the

result in rectangular notation\n");

printf("6 to subtract two complex numbers in the form a +- jb and c +- jd and display the

result in rectangular notation\n");

printf("7 to multiply two complex numbers in the form a +- jb and c +- jd and display the

result in rectangular notation\n");

printf("8 to divide two complex numbers in the form a +- jb and c +- jd and display the

result in rectangular notation\n");

printf("9 to quit \n");

printf("Please enter your choice : ");

scanf("%d", &n);//n is used to store the choice of the user

if(n == 9) // if user enters 9 then break the loop and hence quit the program

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

break;

if(n == 1)

{

printf("Please enter first number : ");

scanf("%f", &a);

printf("Please enter second number : ");

scanf("%f", &b);

printf("Their sum is %f \n", (a+b));

}

if(n == 2)

{

printf("Please enter first number : ");

scanf("%f", &a);

printf("Please enter second number : ");

scanf("%f", &b);

printf("Their difference is i.e a-b = %f \n", (a-b));

if(n == 1)

{

printf("Please enter first number : ");

scanf("%f", &a);

printf("Please enter second number : ");

scanf("%f", &b);

printf("Their sum is %f \n", (a+b));

}

if(n == 2)

{

printf("Please enter first number : ");

scanf("%f", &a);

printf("Please enter second number : ");

scanf("%f", &b);

printf("Their difference is i.e a-b = %f \n", (a-b));

}

if(n == 3)

{

printf("Please enter first number : ");

scanf("%f", &a);

printf("Please enter second number : ");

scanf("%f", &b);

printf("Their product is %f \n", (a*b));

}

if(n == 4)

{

printf("Please enter first number : ");

scanf("%f", &a);

printf("Please enter second number : ");

scanf("%f", &b);

printf("Their division is i.e a/b = %f \n", (a/b));

if(n == 3)

{

printf("Please enter first number : ");

scanf("%f", &a);

printf("Please enter second number : ");

scanf("%f", &b);

printf("Their product is %f \n", (a*b));

}

if(n == 4)

{

printf("Please enter first number : ");

scanf("%f", &a);

printf("Please enter second number : ");

scanf("%f", &b);

printf("Their division is i.e a/b = %f \n", (a/b));

}

if(n == 5)

{

printf("Please enter real part of first number : ");

scanf("%f", &a);

printf("Please enter imaginary part of first number : ");

scanf("%f", &b);

printf("Please enter real part of second number : ");

scanf("%f", &c);

printf("Please enter imaginary part of second number : ");

scanf("%f", &d);

printf("Their sum in rectangular form is %f + j%f \n", (a+c), (b+d));

float k = a+c;

float l = b+d;

if(n == 5)

{

printf("Please enter real part of first number : ");

scanf("%f", &a);

printf("Please enter imaginary part of first number : ");

scanf("%f", &b);

printf("Please enter real part of second number : ");

scanf("%f", &c);

printf("Please enter imaginary part of second number : ");

scanf("%f", &d);

printf("Their sum in rectangular form is %f + j%f \n", (a+c), (b+d));

float k = a+c;

float l = b+d;

Need help grading? Try our AI Grader for instant feedback on your assignments.

printf("The result in polar form : magnitude is %f and angle is %f degrees \n", sqrt(k*k

+ l*l) , atan(l/k)*180 / PI);

}

if(n == 6)

{

printf("Please enter real part of first number : ");

scanf("%f", &a);

printf("Please enter imaginary part of first number : ");

scanf("%f", &b);

printf("Please enter real part of second number : ");

scanf("%f", &c);

printf("Please enter imaginary part of second number : ");

scanf("%f", &d);

printf("Their difference in rectangular form is %f + j%f \n", (a-c), (b-d));

+ l*l) , atan(l/k)*180 / PI);

}

if(n == 6)

{

printf("Please enter real part of first number : ");

scanf("%f", &a);

printf("Please enter imaginary part of first number : ");

scanf("%f", &b);

printf("Please enter real part of second number : ");

scanf("%f", &c);

printf("Please enter imaginary part of second number : ");

scanf("%f", &d);

printf("Their difference in rectangular form is %f + j%f \n", (a-c), (b-d));

float k = a-c;

float l = b-d;

printf("The result in polar form : magnitude is %f and angle is %f degrees \n", sqrt(k*k

+ l*l) , atan(l/k)*180 / PI);

}

if(n == 7)

{

printf("Please enter real part of first number : ");

scanf("%f", &a);

printf("Please enter imaginary part of first number : ");

scanf("%f", &b);

printf("Please enter real part of second number : ");

scanf("%f", &c);

printf("Please enter imaginary part of second number : ");

scanf("%f", &d);

float l = b-d;

printf("The result in polar form : magnitude is %f and angle is %f degrees \n", sqrt(k*k

+ l*l) , atan(l/k)*180 / PI);

}

if(n == 7)

{

printf("Please enter real part of first number : ");

scanf("%f", &a);

printf("Please enter imaginary part of first number : ");

scanf("%f", &b);

printf("Please enter real part of second number : ");

scanf("%f", &c);

printf("Please enter imaginary part of second number : ");

scanf("%f", &d);

//Formula to multiply two complex numbers is : (x+yi)(u+vi) = (xu=yv)+(xv+yu)i

printf("Their product in rectangular form is %f + j%f \n", (a*c - b*d), (a*d + b*c));

float k = (a*c - b*d);

float l =(a*d + b*c);

printf("The result in polar form : magnitude is %f and angle is %f degrees \n", sqrt(k*k

+ l*l) , atan(l/k)*180 / PI);

}

if(n == 8)

{

printf("Please enter real part of first number : ");

scanf("%f", &a);

// The formula to divide two complex numbers is given by

// ((a,b))/((c,d))=((ac+bd)/(c^2+d^2),(bc-ad)/(c^2+d^2)).

printf("Please enter imaginary part of first number : ");

printf("Their product in rectangular form is %f + j%f \n", (a*c - b*d), (a*d + b*c));

float k = (a*c - b*d);

float l =(a*d + b*c);

printf("The result in polar form : magnitude is %f and angle is %f degrees \n", sqrt(k*k

+ l*l) , atan(l/k)*180 / PI);

}

if(n == 8)

{

printf("Please enter real part of first number : ");

scanf("%f", &a);

// The formula to divide two complex numbers is given by

// ((a,b))/((c,d))=((ac+bd)/(c^2+d^2),(bc-ad)/(c^2+d^2)).

printf("Please enter imaginary part of first number : ");

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

scanf("%f", &b);

printf("Please enter real part of second number : ");

scanf("%f", &c);

printf("Please enter imaginary part of second number : ");

scanf("%f", &d);

// The formula to divide two complex numbers is given by

// ((a,b))/((c,d))=((ac+bd)/(c^2+d^2),(bc-ad)/(c^2+d^2)).

float denom = c*c + d*d; // here denominator is denom

printf("Their division in rectangular form is %f + j%f \n", (a*c + b*d)/denom, (b*c -

a*d)/denom);

float k = (a*c + b*d)/denom;

float l =(b*c - a*d)/denom;

printf("The result in polar form : magnitude is %f and angle is %f degrees \n", sqrt(k*k

+ l*l) , atan(l/k)*180 / PI);

printf("Please enter real part of second number : ");

scanf("%f", &c);

printf("Please enter imaginary part of second number : ");

scanf("%f", &d);

// The formula to divide two complex numbers is given by

// ((a,b))/((c,d))=((ac+bd)/(c^2+d^2),(bc-ad)/(c^2+d^2)).

float denom = c*c + d*d; // here denominator is denom

printf("Their division in rectangular form is %f + j%f \n", (a*c + b*d)/denom, (b*c -

a*d)/denom);

float k = (a*c + b*d)/denom;

float l =(b*c - a*d)/denom;

printf("The result in polar form : magnitude is %f and angle is %f degrees \n", sqrt(k*k

+ l*l) , atan(l/k)*180 / PI);

}

}// end of while loop

return 0;

}//end of main

Screenshots of outputs :

}// end of while loop

return 0;

}//end of main

Screenshots of outputs :

Need help grading? Try our AI Grader for instant feedback on your assignments.

1 out of 14