/* To determine a) (Z_1+Z_2)/(Z_1-Z_2) , b) Z_1/Z_2 for two given sets of complex numbers */
#include<stdio.h>
#include<math.h>
int main()
{
float a1, b1, a2, b2, Z_1plusZ_2real, Z_1plusZ_2imp, Real, Imp;
float Z_1byZ_2real, Z_1byZ_2imp, Z_1minusZ_2real, Z_1minusZ_2imp;
printf("Enter the value of Z_1:\n");
scanf("%f%f", &a1, &b1);
printf("Enter the value of Z_2:\n");
scanf("%f%f", &a2, &b2);
Z_1plusZ_2real=a1+a2;
Z_1plusZ_2imp=b1+b2;
Z_1minusZ_2real=a1-a2;
Z_1minusZ_2imp=b1-b2;
printf("\nZ_1=%f+i(%f)", a1, b1);
printf("\n\nZ_2=%f+i(%f)", a2, b2);
printf("\n\nZ_1+Z_2=%f+i(%f)", Z_1plusZ_2real, Z_1plusZ_2imp);
printf("\n\nZ_1-Z_2=%f+i(%f)", Z_1minusZ_2real, Z_1minusZ_2imp);
Z_1byZ_2real=(a1*a2+b1*b2)/(a2*a2+b2*b2);
Z_1byZ_2imp=(a2*b1-a1*b2)/(a2*a2+b2*b2);
printf("\n\nZ_1/Z_2real=%f",Z_1byZ_2real);
printf("\n\nZ_1/Z_2imp=%f", Z_1byZ_2imp);
printf("\n\nZ_1/Z_2=%f+i(%f)", Z_1byZ_2real, Z_1byZ_2imp);
Real=(a1*a1-a2*a2+b1*b1-b2*b2)/(Z_1minusZ_2real*Z_1minusZ_2real+Z_1minusZ_2imp*Z_1minusZ_2imp);
Imp=2*(a1*b2-a2*b1)/(Z_1minusZ_2real*Z_1minusZ_2real+Z_1minusZ_2imp*Z_1minusZ_2imp);
printf("\n\n(Z_1+Z_2)/(Z_1-Z_2)=%f+i(%f)\n", Real, Imp);
return(0);
}
#include<stdio.h>
#include<math.h>
int main()
{
float a1, b1, a2, b2, Z_1plusZ_2real, Z_1plusZ_2imp, Real, Imp;
float Z_1byZ_2real, Z_1byZ_2imp, Z_1minusZ_2real, Z_1minusZ_2imp;
printf("Enter the value of Z_1:\n");
scanf("%f%f", &a1, &b1);
printf("Enter the value of Z_2:\n");
scanf("%f%f", &a2, &b2);
Z_1plusZ_2real=a1+a2;
Z_1plusZ_2imp=b1+b2;
Z_1minusZ_2real=a1-a2;
Z_1minusZ_2imp=b1-b2;
printf("\nZ_1=%f+i(%f)", a1, b1);
printf("\n\nZ_2=%f+i(%f)", a2, b2);
printf("\n\nZ_1+Z_2=%f+i(%f)", Z_1plusZ_2real, Z_1plusZ_2imp);
printf("\n\nZ_1-Z_2=%f+i(%f)", Z_1minusZ_2real, Z_1minusZ_2imp);
Z_1byZ_2real=(a1*a2+b1*b2)/(a2*a2+b2*b2);
Z_1byZ_2imp=(a2*b1-a1*b2)/(a2*a2+b2*b2);
printf("\n\nZ_1/Z_2real=%f",Z_1byZ_2real);
printf("\n\nZ_1/Z_2imp=%f", Z_1byZ_2imp);
printf("\n\nZ_1/Z_2=%f+i(%f)", Z_1byZ_2real, Z_1byZ_2imp);
Real=(a1*a1-a2*a2+b1*b1-b2*b2)/(Z_1minusZ_2real*Z_1minusZ_2real+Z_1minusZ_2imp*Z_1minusZ_2imp);
Imp=2*(a1*b2-a2*b1)/(Z_1minusZ_2real*Z_1minusZ_2real+Z_1minusZ_2imp*Z_1minusZ_2imp);
printf("\n\n(Z_1+Z_2)/(Z_1-Z_2)=%f+i(%f)\n", Real, Imp);
return(0);
}
Comments
Post a Comment