===========================================================================
CODING
#include<all.h>
void main()
{
label:
clrscr();
float a,c,d,r,Theta,Ra,Rb,b,n,n1;
int w=0;
char Re,q,n2,flag='t';
gotoxy(36,1);
cprintf("CALCULATOR");
gotoxy(1,3);
cprintf("--------------------------------------------------------------------------------");
gotoxy(32,5);
cprintf("Functions Available:");
gotoxy(1,7);
cprintf("--------------------------------------------------------------------------------");
gotoxy(20,9);
cprintf("¯ Addition: 1");
gotoxy(20,11);
cprintf("¯ Subtraction: 2");
gotoxy(20,13);
cprintf("¯ Division: 3");
gotoxy(50,9);
cprintf("¯ Multiplication: 4");
gotoxy(50,11);
cprintf("¯ Pol(z): 5");
gotoxy(50,13);
cprintf("¯ Conjugate: 6");
gotoxy(35,15);
cprintf("¯ Sqrt: 7");
gotoxy(1,17);
cprintf("--------------------------------------------------------------------------------");
gotoxy(2,19);
cprintf(" Enter the Function you want to perform: ");
cin>>n;
if(n==1 || n==2 || n==3 || n==4)
{
gotoxy(1,21);
cprintf("--------------------------------------------------------------------------------");
gotoxy(27,22);
cprintf("-----------");
gotoxy(27,23);
cprintf("| z1=a+ib |");
gotoxy(27,24);
cprintf("-----------");
gotoxy(57,22);
cprintf("-----------");
gotoxy(57,23);
cprintf("| z2=c+id |");
gotoxy(57,24);
cprintf("-----------");
gotoxy(32,23);
cscanf("%f",&a);
gotoxy(35,23);
cscanf("%f",&b);
gotoxy(62,23);
cscanf("%f",&c);
gotoxy(65,23);
cscanf("%f",&d);
gotoxy(1,25);
cprintf("--------------------------------------------------------------------------------");
}
else if(n==5 || n==6 || n==7)
{
gotoxy(1,21);
cprintf("--------------------------------------------------------------------------------");
gotoxy(36,22);
cprintf("-----------");
gotoxy(36,23);
cprintf("| z1=a+ib |");
gotoxy(36,24);
cprintf("-----------");
gotoxy(41,23);
cscanf("%f",&a);
gotoxy(44,23);
cscanf("%f",&b);
gotoxy(1,25);
cprintf("--------------------------------------------------------------------------------");
}
if(n==1)
{
Ra=a+c;
Rb=b+c;
}
else if(n==2)
{
Ra=a-c;
Rb=b-d;
}
else if(n==3)
{
if(c*c+d*d==0)
{
flag='f';
Ra=0;
Rb=0;
}
else
Ra=(a*c+b*d)/(c*c+d*d);
Rb=(b*c-a*d)/(c*c+d*d);
}
else if(n==4)
{
Ra=a*c-b*d;
Rb=a*d+b*c;
}
else if(n==5)
{
r=sqrt(a*a+b*b);
Theta=atan(fabs(b)/fabs(a))*180/M_PI;
if(a>=0 && b>=0)
{
w=1;
Theta=Theta;
}
else if(a<0 && b>=0)
{
w=2;
Theta=180-Theta;
}
else if(a<0 && b<0)
{
w=3;
Theta=180+Theta;
}
else if(a>=0 && b<0)
{
w=4;
Theta=360-Theta;
}
}
else if(n==6)
{
Ra=a;
Rb=-b;
}
else if(n==7)
{
Ra=sqrt((a+sqrt(a*a+b*b))/2);
Rb=sqrt((a+sqrt(a*a+b*b))/2-a);
if(a*b<0)
Rb=-Rb;
}
else
{
clrscr();
gotoxy(2,3);
cprintf("Wrong Input!");
gotoxy(2,5);
cprintf("TRY Again? Y-yes N-no :");
cin>>q;
if(q=='Y' || q=='y')
goto label;
else
exit(0);
}
clrscr();
if(n==5)
{
gotoxy(36,2);
printf("CALCULATOR");
gotoxy(1,3);
cprintf("--------------------------------------------------------------------------------");
gotoxy(31,5);
printf("█████████████████████████████");
gotoxy(31,6);
printf("█ Quadrant: %d █",w);
gotoxy(31,7);
printf("█ █");
gotoxy(33,7);
printf("%.1f(cos(%.1f)+i*sin(%.1f))",r,Theta,Theta);
gotoxy(31,8);
printf("█████████████████████████████");
gotoxy(1,20);
cprintf("--------------------------------------------------------------------------------");
gotoxy(1,22);
cprintf(" Do you wish to Start a fresh function (Y-yes N-no): ");
cin>>n2;
if(n2=='Y' || n2=='y')
goto label;
else
exit(0);
}
else
{
gotoxy(36,2);
printf("CALCULATOR");
gotoxy(1,3);
cprintf("--------------------------------------------------------------------------------");
gotoxy(31,5);
printf("████████████████████");
gotoxy(31,6);
printf("█ █");
gotoxy(31,7);
printf("█ █");
gotoxy(33,7);
if(flag=='t')
printf("%.1f+i*%.1f",Ra,Rb);
else if(flag=='f')
printf("-ERROR-");
gotoxy(31,8);
printf("████████████████████");
gotoxy(31,9);
printf("█ sqrt █ pow ██ = ██");
gotoxy(31,10);
printf("████████████████████");
gotoxy(31,11);
printf("█ 7 █ 8 █ 9 █ - █");
gotoxy(31,12);
printf("████████████████████");
gotoxy(31,13);
printf("█ 4 █ 5 █ 6 █ / █");
gotoxy(31,14);
printf("████████████████████");
gotoxy(31,15);
printf("█ 1 █ 2 █ 3 █ * █");
gotoxy(31,16);
printf("████████████████████");
gotoxy(31,17);
printf("█ . █ 0 █ % █ + █");
gotoxy(31,18);
printf("████████████████████");
gotoxy(1,20);
cprintf("--------------------------------------------------------------------------------");
}
gotoxy(1,22);
cprintf(" Should the Result be Saved and perform another function with it (Y-yes N-no): ");
cin>>Re;
if(Re=='Y' || Re=='y')
{
label1:
clrscr();
gotoxy(36,1);
cprintf("CALCULATOR");
gotoxy(1,3);
cprintf("--------------------------------------------------------------------------------");
gotoxy(32,5);
cprintf("Functions Available:");
gotoxy(1,7);
cprintf("--------------------------------------------------------------------------------");
gotoxy(20,9);
cprintf("¯ Addition: 1");
gotoxy(20,11);
cprintf("¯ Subtraction: 2");
gotoxy(20,13);
cprintf("¯ Division: 3");
gotoxy(50,9);
cprintf("¯ Multiplication: 4");
gotoxy(50,11);
cprintf("¯ Pol(z): 5");
gotoxy(50,13);
cprintf("¯ Conjugate: 6");
gotoxy(35,15);
cprintf("¯ Sqrt: 7");
gotoxy(1,17);
cprintf("--------------------------------------------------------------------------------");
gotoxy(2,19);
cprintf("Enter the Function you want to perform: ");
cin>>n1;
if(n1==1 || n1==2 || n1==3 || n1==4)
{
gotoxy(1,21);
cprintf("--------------------------------------------------------------------------------");
gotoxy(36,22);
cprintf("-----------");
gotoxy(36,23);
cprintf("| z1=a+ib |");
gotoxy(36,24);
cprintf("-----------");
gotoxy(41,23);
cscanf("%f",&a);
gotoxy(44,23);
cscanf("%f",&b);
gotoxy(1,25);
cprintf("--------------------------------------------------------------------------------");
}
else if(n1==5 || n1==6 || n1==7);
}
else if(Re=='N' || Re=='n')
{
gotoxy(1,23);
cprintf(" Do you wish to Start a fresh function (Y-yes N-no): ");
cin>>n2;
if(n2=='Y' || n2=='y')
goto label;
else
exit(0);
}
if(n1==1)
{
Ra=Ra+a;
Rb=Rb+b;
}
else if(n1==2)
{
Ra=Ra-a;
Rb=Rb-b;
}
else if(n1==3)
{
if(a*a+b*b==0)
{
flag='f';
Ra=0;
Rb=0;
}
else
{
Ra=(Ra*a+Rb*b)/(a*a+b*b);
Rb=(Rb*a-Ra*b)/(a*a+b*b);
}
}
else if(n1==4)
{
Ra=Ra*a-Rb*b;
Rb=Rb*a+Ra*b;
}
else if(n1==5)
{
r=sqrt(Ra*Ra+Rb*Rb);
Theta=atan(fabs(Rb)/fabs(Ra));
if(Ra>=0 && Rb>=0)
{
w=1;
Theta=Theta;
}
else if(Ra<0 && Rb>=0)
{
w=2;
Theta=180-Theta;
}
else if(Ra<0 && Rb<0)
{
w=3;
Theta=180+Theta;
}
else if(Ra>=0 && Rb<0)
{
w=4;
Theta=360-Theta;
}
}
else if(n1==6)
{
Ra=Ra;
Rb=-Rb;
}
else if(n1==7)
{
Ra=sqrt((Ra*Ra+Rb*Rb+Ra)/2);
Rb=sqrt((Ra*Ra+Rb*Rb-Ra)/2);
if(a*b<0)
Rb=-Rb;
}
else
{
clrscr();
gotoxy(2,3);
cprintf("Wrong Input!");
gotoxy(2,5);
cprintf("TRY Again? Y-yes N-no :");
cin>>q;
if(q=='Y' || q=='y')
goto label1;
else
exit(0);
}
clrscr();
if(n1==5)
{
gotoxy(36,2);
printf("CALCULATOR");
gotoxy(1,3);
cprintf("--------------------------------------------------------------------------------");
gotoxy(31,5);
printf("████████████████████████████");
gotoxy(31,6);
printf("█ Quadrant: %d █",w);
gotoxy(31,7);
printf("█ █");
gotoxy(33,7);
printf("%.1f(cos(%.1f)+i*sin(%.1f))",r,Theta,Theta);
gotoxy(31,8);
printf("████████████████████████████");
gotoxy(1,20);
cprintf("--------------------------------------------------------------------------------");
gotoxy(1,22);
cprintf(" Do you wish to Start a fresh function (Y-yes N-no): ");
cin>>n2;
if(n2=='Y' || n2=='y')
goto label;
else
exit(0);
}
else
{
gotoxy(36,2);
printf("CALCULATOR");
gotoxy(1,3);
cprintf("--------------------------------------------------------------------------------");
gotoxy(31,5);
printf("████████████████████");
gotoxy(31,6);
printf("█ █");
gotoxy(31,7);
printf("█ █");
gotoxy(33,7);
if(flag=='t')
printf("%.1f+i*%.1f",Ra,Rb);
else if(flag=='f')
printf("-ERROR-");
gotoxy(31,8);
printf("████████████████████");
gotoxy(31,9);
printf("█ sqrt █ pow ██ = ██");
gotoxy(31,10);
printf("████████████████████");
gotoxy(31,11);
printf("█ 7 █ 8 █ 9 █ - █");
gotoxy(31,12);
printf("████████████████████");
gotoxy(31,13);
printf("█ 4 █ 5 █ 6 █ / █");
gotoxy(31,14);
printf("████████████████████");
gotoxy(31,15);
printf("█ 1 █ 2 █ 3 █ * █");
gotoxy(31,16);
printf("████████████████████");
gotoxy(31,17);
printf("█ . █ 0 █ % █ + █");
gotoxy(31,18);
printf("████████████████████");
gotoxy(1,20);
cprintf("--------------------------------------------------------------------------------");
}
gotoxy(1,21);
cprintf(" Should the Result be Saved and perform another function with it (Y-yes N-no): ");
cin>>Re;
if(Re=='Y' || Re=='y')
goto label1;
else if(Re=='N' || Re=='n')
{
gotoxy(1,22);
cprintf(" Do you wish to Start a fresh function (Y-yes N-no): ");
cin>>n2;
if(n2=='Y' || n2=='y')
goto label;
else
exit(0);
}
getch();
}
CODING
#include<all.h>
void main()
{
label:
clrscr();
float a,c,d,r,Theta,Ra,Rb,b,n,n1;
int w=0;
char Re,q,n2,flag='t';
gotoxy(36,1);
cprintf("CALCULATOR");
gotoxy(1,3);
cprintf("--------------------------------------------------------------------------------");
gotoxy(32,5);
cprintf("Functions Available:");
gotoxy(1,7);
cprintf("--------------------------------------------------------------------------------");
gotoxy(20,9);
cprintf("¯ Addition: 1");
gotoxy(20,11);
cprintf("¯ Subtraction: 2");
gotoxy(20,13);
cprintf("¯ Division: 3");
gotoxy(50,9);
cprintf("¯ Multiplication: 4");
gotoxy(50,11);
cprintf("¯ Pol(z): 5");
gotoxy(50,13);
cprintf("¯ Conjugate: 6");
gotoxy(35,15);
cprintf("¯ Sqrt: 7");
gotoxy(1,17);
cprintf("--------------------------------------------------------------------------------");
gotoxy(2,19);
cprintf(" Enter the Function you want to perform: ");
cin>>n;
if(n==1 || n==2 || n==3 || n==4)
{
gotoxy(1,21);
cprintf("--------------------------------------------------------------------------------");
gotoxy(27,22);
cprintf("-----------");
gotoxy(27,23);
cprintf("| z1=a+ib |");
gotoxy(27,24);
cprintf("-----------");
gotoxy(57,22);
cprintf("-----------");
gotoxy(57,23);
cprintf("| z2=c+id |");
gotoxy(57,24);
cprintf("-----------");
gotoxy(32,23);
cscanf("%f",&a);
gotoxy(35,23);
cscanf("%f",&b);
gotoxy(62,23);
cscanf("%f",&c);
gotoxy(65,23);
cscanf("%f",&d);
gotoxy(1,25);
cprintf("--------------------------------------------------------------------------------");
}
else if(n==5 || n==6 || n==7)
{
gotoxy(1,21);
cprintf("--------------------------------------------------------------------------------");
gotoxy(36,22);
cprintf("-----------");
gotoxy(36,23);
cprintf("| z1=a+ib |");
gotoxy(36,24);
cprintf("-----------");
gotoxy(41,23);
cscanf("%f",&a);
gotoxy(44,23);
cscanf("%f",&b);
gotoxy(1,25);
cprintf("--------------------------------------------------------------------------------");
}
if(n==1)
{
Ra=a+c;
Rb=b+c;
}
else if(n==2)
{
Ra=a-c;
Rb=b-d;
}
else if(n==3)
{
if(c*c+d*d==0)
{
flag='f';
Ra=0;
Rb=0;
}
else
Ra=(a*c+b*d)/(c*c+d*d);
Rb=(b*c-a*d)/(c*c+d*d);
}
else if(n==4)
{
Ra=a*c-b*d;
Rb=a*d+b*c;
}
else if(n==5)
{
r=sqrt(a*a+b*b);
Theta=atan(fabs(b)/fabs(a))*180/M_PI;
if(a>=0 && b>=0)
{
w=1;
Theta=Theta;
}
else if(a<0 && b>=0)
{
w=2;
Theta=180-Theta;
}
else if(a<0 && b<0)
{
w=3;
Theta=180+Theta;
}
else if(a>=0 && b<0)
{
w=4;
Theta=360-Theta;
}
}
else if(n==6)
{
Ra=a;
Rb=-b;
}
else if(n==7)
{
Ra=sqrt((a+sqrt(a*a+b*b))/2);
Rb=sqrt((a+sqrt(a*a+b*b))/2-a);
if(a*b<0)
Rb=-Rb;
}
else
{
clrscr();
gotoxy(2,3);
cprintf("Wrong Input!");
gotoxy(2,5);
cprintf("TRY Again? Y-yes N-no :");
cin>>q;
if(q=='Y' || q=='y')
goto label;
else
exit(0);
}
clrscr();
if(n==5)
{
gotoxy(36,2);
printf("CALCULATOR");
gotoxy(1,3);
cprintf("--------------------------------------------------------------------------------");
gotoxy(31,5);
printf("█████████████████████████████");
gotoxy(31,6);
printf("█ Quadrant: %d █",w);
gotoxy(31,7);
printf("█ █");
gotoxy(33,7);
printf("%.1f(cos(%.1f)+i*sin(%.1f))",r,Theta,Theta);
gotoxy(31,8);
printf("█████████████████████████████");
gotoxy(1,20);
cprintf("--------------------------------------------------------------------------------");
gotoxy(1,22);
cprintf(" Do you wish to Start a fresh function (Y-yes N-no): ");
cin>>n2;
if(n2=='Y' || n2=='y')
goto label;
else
exit(0);
}
else
{
gotoxy(36,2);
printf("CALCULATOR");
gotoxy(1,3);
cprintf("--------------------------------------------------------------------------------");
gotoxy(31,5);
printf("████████████████████");
gotoxy(31,6);
printf("█ █");
gotoxy(31,7);
printf("█ █");
gotoxy(33,7);
if(flag=='t')
printf("%.1f+i*%.1f",Ra,Rb);
else if(flag=='f')
printf("-ERROR-");
gotoxy(31,8);
printf("████████████████████");
gotoxy(31,9);
printf("█ sqrt █ pow ██ = ██");
gotoxy(31,10);
printf("████████████████████");
gotoxy(31,11);
printf("█ 7 █ 8 █ 9 █ - █");
gotoxy(31,12);
printf("████████████████████");
gotoxy(31,13);
printf("█ 4 █ 5 █ 6 █ / █");
gotoxy(31,14);
printf("████████████████████");
gotoxy(31,15);
printf("█ 1 █ 2 █ 3 █ * █");
gotoxy(31,16);
printf("████████████████████");
gotoxy(31,17);
printf("█ . █ 0 █ % █ + █");
gotoxy(31,18);
printf("████████████████████");
gotoxy(1,20);
cprintf("--------------------------------------------------------------------------------");
}
gotoxy(1,22);
cprintf(" Should the Result be Saved and perform another function with it (Y-yes N-no): ");
cin>>Re;
if(Re=='Y' || Re=='y')
{
label1:
clrscr();
gotoxy(36,1);
cprintf("CALCULATOR");
gotoxy(1,3);
cprintf("--------------------------------------------------------------------------------");
gotoxy(32,5);
cprintf("Functions Available:");
gotoxy(1,7);
cprintf("--------------------------------------------------------------------------------");
gotoxy(20,9);
cprintf("¯ Addition: 1");
gotoxy(20,11);
cprintf("¯ Subtraction: 2");
gotoxy(20,13);
cprintf("¯ Division: 3");
gotoxy(50,9);
cprintf("¯ Multiplication: 4");
gotoxy(50,11);
cprintf("¯ Pol(z): 5");
gotoxy(50,13);
cprintf("¯ Conjugate: 6");
gotoxy(35,15);
cprintf("¯ Sqrt: 7");
gotoxy(1,17);
cprintf("--------------------------------------------------------------------------------");
gotoxy(2,19);
cprintf("Enter the Function you want to perform: ");
cin>>n1;
if(n1==1 || n1==2 || n1==3 || n1==4)
{
gotoxy(1,21);
cprintf("--------------------------------------------------------------------------------");
gotoxy(36,22);
cprintf("-----------");
gotoxy(36,23);
cprintf("| z1=a+ib |");
gotoxy(36,24);
cprintf("-----------");
gotoxy(41,23);
cscanf("%f",&a);
gotoxy(44,23);
cscanf("%f",&b);
gotoxy(1,25);
cprintf("--------------------------------------------------------------------------------");
}
else if(n1==5 || n1==6 || n1==7);
}
else if(Re=='N' || Re=='n')
{
gotoxy(1,23);
cprintf(" Do you wish to Start a fresh function (Y-yes N-no): ");
cin>>n2;
if(n2=='Y' || n2=='y')
goto label;
else
exit(0);
}
if(n1==1)
{
Ra=Ra+a;
Rb=Rb+b;
}
else if(n1==2)
{
Ra=Ra-a;
Rb=Rb-b;
}
else if(n1==3)
{
if(a*a+b*b==0)
{
flag='f';
Ra=0;
Rb=0;
}
else
{
Ra=(Ra*a+Rb*b)/(a*a+b*b);
Rb=(Rb*a-Ra*b)/(a*a+b*b);
}
}
else if(n1==4)
{
Ra=Ra*a-Rb*b;
Rb=Rb*a+Ra*b;
}
else if(n1==5)
{
r=sqrt(Ra*Ra+Rb*Rb);
Theta=atan(fabs(Rb)/fabs(Ra));
if(Ra>=0 && Rb>=0)
{
w=1;
Theta=Theta;
}
else if(Ra<0 && Rb>=0)
{
w=2;
Theta=180-Theta;
}
else if(Ra<0 && Rb<0)
{
w=3;
Theta=180+Theta;
}
else if(Ra>=0 && Rb<0)
{
w=4;
Theta=360-Theta;
}
}
else if(n1==6)
{
Ra=Ra;
Rb=-Rb;
}
else if(n1==7)
{
Ra=sqrt((Ra*Ra+Rb*Rb+Ra)/2);
Rb=sqrt((Ra*Ra+Rb*Rb-Ra)/2);
if(a*b<0)
Rb=-Rb;
}
else
{
clrscr();
gotoxy(2,3);
cprintf("Wrong Input!");
gotoxy(2,5);
cprintf("TRY Again? Y-yes N-no :");
cin>>q;
if(q=='Y' || q=='y')
goto label1;
else
exit(0);
}
clrscr();
if(n1==5)
{
gotoxy(36,2);
printf("CALCULATOR");
gotoxy(1,3);
cprintf("--------------------------------------------------------------------------------");
gotoxy(31,5);
printf("████████████████████████████");
gotoxy(31,6);
printf("█ Quadrant: %d █",w);
gotoxy(31,7);
printf("█ █");
gotoxy(33,7);
printf("%.1f(cos(%.1f)+i*sin(%.1f))",r,Theta,Theta);
gotoxy(31,8);
printf("████████████████████████████");
gotoxy(1,20);
cprintf("--------------------------------------------------------------------------------");
gotoxy(1,22);
cprintf(" Do you wish to Start a fresh function (Y-yes N-no): ");
cin>>n2;
if(n2=='Y' || n2=='y')
goto label;
else
exit(0);
}
else
{
gotoxy(36,2);
printf("CALCULATOR");
gotoxy(1,3);
cprintf("--------------------------------------------------------------------------------");
gotoxy(31,5);
printf("████████████████████");
gotoxy(31,6);
printf("█ █");
gotoxy(31,7);
printf("█ █");
gotoxy(33,7);
if(flag=='t')
printf("%.1f+i*%.1f",Ra,Rb);
else if(flag=='f')
printf("-ERROR-");
gotoxy(31,8);
printf("████████████████████");
gotoxy(31,9);
printf("█ sqrt █ pow ██ = ██");
gotoxy(31,10);
printf("████████████████████");
gotoxy(31,11);
printf("█ 7 █ 8 █ 9 █ - █");
gotoxy(31,12);
printf("████████████████████");
gotoxy(31,13);
printf("█ 4 █ 5 █ 6 █ / █");
gotoxy(31,14);
printf("████████████████████");
gotoxy(31,15);
printf("█ 1 █ 2 █ 3 █ * █");
gotoxy(31,16);
printf("████████████████████");
gotoxy(31,17);
printf("█ . █ 0 █ % █ + █");
gotoxy(31,18);
printf("████████████████████");
gotoxy(1,20);
cprintf("--------------------------------------------------------------------------------");
}
gotoxy(1,21);
cprintf(" Should the Result be Saved and perform another function with it (Y-yes N-no): ");
cin>>Re;
if(Re=='Y' || Re=='y')
goto label1;
else if(Re=='N' || Re=='n')
{
gotoxy(1,22);
cprintf(" Do you wish to Start a fresh function (Y-yes N-no): ");
cin>>n2;
if(n2=='Y' || n2=='y')
goto label;
else
exit(0);
}
getch();
}
===========================================================================
No comments:
Post a Comment