Skip to content

Instantly share code, notes, and snippets.

@wohhie
Created July 21, 2016 05:49
Show Gist options
  • Save wohhie/65cb792279cc26c696ae1bdcd0b6a238 to your computer and use it in GitHub Desktop.
Save wohhie/65cb792279cc26c696ae1bdcd0b6a238 to your computer and use it in GitHub Desktop.
Summation of Complex Number
#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