C programming code
#include <stdio.h>
#include<conio.h>
struct complex
{
int real, img;
};
void main()
{
struct complex a, b, c;
clrscr();
printf("Enter a and b where a + ib is the first complex number.\n");
printf("a = ");
scanf("%d", &a.real);
printf("b = ");
scanf("%d", &a.img);
printf("Enter c and d where c + id is the second complex number.\n");
printf("c = ");
scanf("%d", &b.real);
printf("d = ");
scanf("%d", &b.img);
c.real = a.real + b.real;
c.img = a.img + b.img;
if ( c.img >= 0 )
printf("Sum of two complex numbers = %d + %di\n",c.real,c.img);
else
printf("Sum of two complex numbers = %d %di\n",c.real,c.img);
getch();
}
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhzFv580xP8_PRzbcbNbdp3clEdP0TkZPldT_rtKKzf_sok2KxlRlWAVW3jKGpv5pURDFNiXFcCNVwgfkQ-DY7dg_apcYeBLbWECdOLSoI_fTzmy2MFaC-H5ThqRD0ytnHzpfR_UUXDog/s1600/Untitled.png)
No comments:
Post a Comment