bsc

Comprehensive codebase and cou...
Log | Files | Refs | Activity | README | LICENSE

root / semester_1 / assignment-secondary / assignment-s-23.c

assignment-s-23.c (547B)


      1 /* Write a program to add two complex numbers using structures. */
      2 
      3 #include <stdio.h>
      4 #include <stdlib.h>
      5 
      6 struct complex_number
      7 {
      8     double real;
      9     double imaginary;
     10 };
     11 
     12 int main()
     13 {
     14     struct complex_number a, b;
     15     printf("Enter the 1st complex number in this format (a+bi): ");
     16     scanf("%lf+%lfi", &a.real, &a.imaginary);
     17     printf("Enter the 2nd complex number in this format (a+bi): ");
     18     scanf("%lf+%lfi", &b.real, &b.imaginary);
     19 
     20     printf("Result = %-2g + %-2.2g", a.real + b.real, a.imaginary + b.imaginary);
     21     return 0;
     22 }
© notamitgamer • Site Built: 2026-09-05 01:53:16 UTC • git-mirror commit: c170d72 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror