C program for addition and subtraction of two complex numbers.

source code


#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);
  getch();

Comments

Popular posts from this blog

8086 STRING MANIPULATION –FIND AND REPLACE A WORD

Animated Circles In C++

C program to find out the sum of series 1 + 2 + …. + n.