C Program to find addition and subtraction of complex numbers - c programs
Write a C Program to find addition and subtraction of complex numbers - add two complex numbers using c - subtract two complex numbers in c language
//Write a C Program to find addition and subtraction of complex numbers - add two complex numbers using c - subtract two complex numbers in c language
#include<stdio.h>
int main(){
int a,b,c,d,x,y;
printf("\nEnter the first complex number:");
scanf("%d%d",&a,&b);
printf("\nEnter the second complex number:");
scanf("%d%d",&c,&d);
if(b<0)
printf("%d-i\n",a-b);
else
printf("d+i\n",a+b);
if(d<0)
printf("d-i\n",c-d);
else
printf("%d+i\n",c+d);
printf("\nADDITION ");
x=a+c;
y=b+d;
if(y>0)
printf("%d-i%d",x,-y);
else
printf("%d+i%d",x,+y);
printf("\n\nSUBTRACTION ");
x=a-c;
y=b-d;
if(y<0)
printf("%d-i%d",x,-y);
else
printf("%d+i%d",x,+y);
return 0;
}
#include<stdio.h>
int main(){
int a,b,c,d,x,y;
printf("\nEnter the first complex number:");
scanf("%d%d",&a,&b);
printf("\nEnter the second complex number:");
scanf("%d%d",&c,&d);
if(b<0)
printf("%d-i\n",a-b);
else
printf("d+i\n",a+b);
if(d<0)
printf("d-i\n",c-d);
else
printf("%d+i\n",c+d);
printf("\nADDITION ");
x=a+c;
y=b+d;
if(y>0)
printf("%d-i%d",x,-y);
else
printf("%d+i%d",x,+y);
printf("\n\nSUBTRACTION ");
x=a-c;
y=b-d;
if(y<0)
printf("%d-i%d",x,-y);
else
printf("%d+i%d",x,+y);
return 0;
}
No comments:
Post a Comment