Created
July 21, 2016 05:49
-
-
Save wohhie/65cb792279cc26c696ae1bdcd0b6a238 to your computer and use it in GitHub Desktop.
Summation of Complex Number
This file contains 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
#include <stdio.h> | |
struct complex { | |
int real_part, | |
imaginary_part; | |
}; | |
int main() { | |
struct complex num1, num2; | |
struct complex result; | |
printf("Enter number in complex way a + ib:"); | |
printf("\nEnter the first number real part: "); | |
scanf("%d", &num1.real_part); | |
printf("\nEnter the first number imaginary part: "); | |
scanf("%d", &num1.imaginary_part); | |
printf("\nEnter the second number real part: "); | |
scanf("%d", &num2.real_part); | |
printf("\nEnter the second number imaginary part: "); | |
scanf("%d", &num2.imaginary_part); | |
result.real_part = num1.real_part + num2.real_part; | |
result.imaginary_part = num1.imaginary_part + num2.imaginary_part; | |
printf("\nThe result is: %d + i%d", result.real_part, result.imaginary_part); | |
printf("\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment