#include
#include
#include
#include
const float pi=3.141592653569793238462643;
float gtt();
float sin1(float x);
float cos1(float x);
float powe(float x,int y);
char ch;
float va1=0,va2=0;
main()
{
clrscr();
va1=gtt();
do
{
switch(ch)
{
case '+':
clrscr();
va2=gtt();
va1=va1+va2;
break;
case '-':
clrscr();
va2=gtt();
va1=va1-va2;
break;
case '*':
clrscr();
va2=gtt();
va1=va1*va2;
break;
case '/':
clrscr();
va2=gtt();
va1=va1/va2;
break;
case 's':
clrscr();
va1=(va1*3.14)/180;
va1=sin1(va1);
break;
case 'c':
clrscr();
va1=(va1*3.14)/180;
va1=cos1(va1);
break;
case 't':
clrscr();
va1=(va1*3.14)/180;
va1=sin1(va1)/cos1(va1);
break;
case 'o':
clrscr();
va1=(va1*3.14)/180;
va1=cos1(va1)/sin1(va1);
break;
case 13:
clrscr();
printf ("\n %f",va1);
break;
}
}
while (ch!=27);
}
/*****************************get*********/
float gtt()
{
float v;
int i=0;
char h='w';
char s[20];
strcpy (s,"");
do
{
ch=getche();
if (ch=='0'|| ch=='1' || ch=='2'|| ch=='3'|| ch=='4' || ch=='5'
||ch=='6'|| ch=='7' || ch=='8'|| ch=='9')
{
s[i+1]=NULL;
s[i]=ch;
i++;
}
if (ch=='+'|| ch=='-' || ch=='*'|| ch=='/'|| ch=='s'|| ch=='c'|| ch=='t'|| ch=='o'|| ch==13) h=13;
} while(h!=13);
v=atof(s);
return(v);
}
/**************sin**************/
float sin1(float x)
{
float ss;
ss=(x-(powe(x,3)/6)+(powe(x,5)/120)-(powe(x,7)/5040)+(powe(x,9)/362880));
return(ss);
}
/**************cos**************/
float cos1(float x)
{
float ss;
ss=(1-(powe(x,2)/2)+(powe(x,4)/24)-(powe(x,6)/720)+(powe(x,8)/40320));
return(ss);
}
/**************tavan**************/
float powe(float x,int y)
{
int i;
float tt=1;
for (i=1;i<=y;i++)
tt=tt*x;
return(tt);
}