Ask a question to Desklib · AI bot

14 Pages1822 Words263 Views

Added on 2019-09-25

BookmarkShareRelated Documents

ReportTo multiply two complex numbers I use the formulaHere, (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 thesign 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 convert rectangular form of complex number to polar form I used the formulaWe have a + ibThen polar form is sqrt(a*a + b*b) , atan(b/a)*180 / PIIn C PI is defined in math.h:#define PI 3.14159265358979323846I 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.14159265358979323846int 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

Related Documents

|16

|944

|457