assignment-s-23.c (683B)
1 /* 2 * Author: Amit Dutta (amitdutta4255@gmail.com) | Date: 18 Jan 2026 3 * Repo: https://github.com/notamitgamer/bsc 4 * License: MIT 5 */ 6 7 /* Write a program to add two complex numbers using structures. */ 8 9 #include <stdio.h> 10 #include <stdlib.h> 11 12 struct complex_number 13 { 14 double real; 15 double imaginary; 16 }; 17 18 int main() 19 { 20 struct complex_number a, b; 21 printf("Enter the 1st complex number in this format (a+bi): "); 22 scanf("%lf+%lfi", &a.real, &a.imaginary); 23 printf("Enter the 2nd complex number in this format (a+bi): "); 24 scanf("%lf+%lfi", &b.real, &b.imaginary); 25 26 printf("Result = %-2g + %-2.2g", a.real + b.real, a.imaginary + b.imaginary); 27 return 0; 28 }