===========================================================================
CODING
#include<iostream.h>
#include<conio.h>
int a,b,c,d,n,Ra,Rb;
void input(int &x, int &y, int);
void operation();
void check();
void output();
void main()
{
clrscr();
input(a,b,1);
input(c,d,2);
operation();
check();
output();
getch();
getch();
}
void input(int &x,int &y,int l)
{
gotoxy(1,l);
cprintf(" Enter \"Complex Number\" in : ( )+i*( )");
gotoxy(33,l);
cscanf("%d",&x);
gotoxy(40,l);
cscanf("%d",&y);
}
void operation()
{
gotoxy(1,4);
cprintf(" Choose: ");
cprintf("\n\r ÄÄÄÄÄÄ ");
cprintf("\n\r1.) Addition");
cprintf("\n\r2.) Subtraction");
cprintf("\n\r3.) Multiplication");
cprintf("\n\r4.) Division");
cprintf("\n\r\nEnter Your Option: ");
cscanf("%d",&n);
}
void check()
{
if(n==1)
{
Ra=a+c;
Rb=b+d;
}
else if(n==2)
{
Ra=a-c;
Rb=b-d;
}
else if(n==3)
{
Ra=a*c-b*d;
Rb=a*d+b*c;
}
else if(n==4)
{
Ra=(a*c+b*d)/(c*c+d*d);
Rb=(b*c-a*d)/(c*c+d*d);
}
}
void output()
{
if(Rb>=0)
cprintf("\n\r\nAnswer: %d+%di",Ra,Rb);
else
cprintf("\n\r\nAnswer: %d%di",Ra,Rb);
}
CODING
#include<iostream.h>
#include<conio.h>
int a,b,c,d,n,Ra,Rb;
void input(int &x, int &y, int);
void operation();
void check();
void output();
void main()
{
clrscr();
input(a,b,1);
input(c,d,2);
operation();
check();
output();
getch();
getch();
}
void input(int &x,int &y,int l)
{
gotoxy(1,l);
cprintf(" Enter \"Complex Number\" in : ( )+i*( )");
gotoxy(33,l);
cscanf("%d",&x);
gotoxy(40,l);
cscanf("%d",&y);
}
void operation()
{
gotoxy(1,4);
cprintf(" Choose: ");
cprintf("\n\r ÄÄÄÄÄÄ ");
cprintf("\n\r1.) Addition");
cprintf("\n\r2.) Subtraction");
cprintf("\n\r3.) Multiplication");
cprintf("\n\r4.) Division");
cprintf("\n\r\nEnter Your Option: ");
cscanf("%d",&n);
}
void check()
{
if(n==1)
{
Ra=a+c;
Rb=b+d;
}
else if(n==2)
{
Ra=a-c;
Rb=b-d;
}
else if(n==3)
{
Ra=a*c-b*d;
Rb=a*d+b*c;
}
else if(n==4)
{
Ra=(a*c+b*d)/(c*c+d*d);
Rb=(b*c-a*d)/(c*c+d*d);
}
}
void output()
{
if(Rb>=0)
cprintf("\n\r\nAnswer: %d+%di",Ra,Rb);
else
cprintf("\n\r\nAnswer: %d%di",Ra,Rb);
}
===========================================================================
No comments:
Post a Comment