#include<stdio.h>
#include<conio.h>
#include<math.h>
void header()
{
printf("\n");
printf("Built and Designed by Arslan-ud-Din-Shafiq\n\nReg. No .DDP-SP14-BSE-005");
printf("\n");
}
void line()
{
int i;
for(i=1;i<=48;i++)
printf("=");
}
float sum(float a,float b)
{
return a+b;
}
float subtract(float c , float d)
{
return c-d;
}
float multiply(float e,float f)
{
return e*f;
}
float divide(float g,float h)
{
return g/h;
}
int mod(int i,int j)
{
return i%j;
}
int fact(int k)
{
int i,p=1;
for(i=1;i<=k;i++)
p*=i;
return p;
}
int pwr(int n , int r)
{
int k, result=1;
for(k=1;k<=r;k++)
result*=n;
return result;
}
int main()
{
float x,y;
char m,s,c,t;
line();
header();
line();
while(m!=-1)
{
printf("\nEnter 1st Number = ");
scanf("%f",&x);
printf("\nEnter 2nd Number = ");
scanf("%f",&y);
printf("\nYou can use following Arithmatic Operations (+,-,*,^,/,%,!)\n(s) for sin \n(c)for cos \n(t) for tan \n(l) for log with base e\n(r) for square root \n(L) for log with base 10\n(z) for sec x\n(v) for cosec x\n(w) for cot x\n PRESS (e) tp END the Program = ");
m=getche();
printf("\n");
switch(m)
{
case'+':
line();
printf("\nSum of %.2f and %.2f is = %.2f\n\n",x,y,sum(x,y));
line();
break;
case'-':
line();
printf("\nSubtraction of %.2f and %.2f is = %.2f\n",x,y,subtract(x,y));
line();
break;
case'*':
line();
printf("\nProduct of %.2f and %.2f is = %.2f\n",x,y,multiply(x,y));
line();
break;
case'/':
line();
printf("\nDivision of %.2f and %.2f is = %.2f\n",x,y,divide(x,y));
line();
break;
case'%':
line();
printf("\nModulus of %d and %d is = %d\n",x,y,mod(x,y));
line();
break;
case'!':
line();
printf("\nFactorial of %d is = %d\n",x,fact(x));
line();
printf("\nFactorial of %d is = %d\n",y,fact(y));
line();
break;
case'^':
line();
printf("\n%d raised to power %d is = %d\n",x,y,pwr(x,y));
line();
break;
case'r':
line();
printf("\nSquare root of %.2f is = %.2f",x,sqrt(x));
printf("\nSquare root of %.2f is = %.2f",y,sqrt(y));
line();
break;
case's':
printf("Press (a) if 'x' is in radian or (b) if 'x' is in degrees : ");
s=getche();
printf("\n");
switch(s)
{
case'a':
line();
printf("\nsin %.1f = %.4f\n",x,sin(x));
line();
printf("\nsin %.1f = %.4f\n",y,sin(y));
line();
break;
case'b':
{ float i,j;
i=x*0.01746;
j=y*0.01746;
line();
printf("\nsin %.1f = %.4f\n",x,sin(i));
line();
printf("\nsin %.1f = %.4f\n",y,sin(j));
line();
}
break;
}
break;
case'c':
printf("Press (a) if 'x' is in radian or (b) if 'x' is in degrees : ");
c=getche();
printf("\n");
switch(c)
{
case'a':
line();
printf("\ncos %.1f = %.4f\n",x,cos(x));
line();
printf("\ncos %.1f = %.4f\n",y,cos(y));
line();
break;
case'b':
{ float i,j;
i=x*0.01746;
j=y*0.01746;
line();
printf("\ncos %.1f = %.4f\n",x,cos(i));
line();
printf("\ncos %.1f = %.4f\n",y,cos(j));
line();
}
break;
}
break;
case't':
printf("\nPress (a) if 'x' is in radian or (b) if 'x' is in degrees : ");
t=getche();
printf("\n");
switch(t)
{
case'a':
line();
printf("\ntan %.1f = %.4f\n",x,tan(x));
line();
printf("\ntan %.1f = %.4f\n",y,tan(y));
line();
break;
case'b':
{ float i,j;
i=x*0.01746;
j=y*0.01746;
line();
printf("\ntan %.1f = %.4f\n",x,tan(i));
line();
printf("\ntan %.1f = %.4f\n",y,tan(j));
line();
}
break;
}
break;
case'l':
line();
printf("\nNatural log of %.2f = %.2f \n",x,log(x));
line();
printf("\nNatural log of %.2f = %.2f \n",y,log(y));
line();
break;
case'L':
line();
printf("\nLog of %.2f with base 10 = %.2f\n",x,log10(x));
line();
printf("\nLog of %.2f with base 10 = %.2f\n",y,log10(y));
line();
break;
case'e':
{
int i;
printf("\nEnter -1 to end : ");
scanf("%d",&i);
printf("\n");
if(i==-1)
{
line();
printf("\nYou are getting out of this program.....Press Enter.\n");
line();
return 0;
}
}
break;
case'z':
{
float v,w;
v=1/(cos(x));
w=1/(cos(y));
printf("sec %.2f = %.2f",x,v);
printf("sec %.2f = %.2f",y,w);
}
break;
case'v':
{
float a,b;
b=1/(sin(x));
a=1/(sin(y));
printf("cosec %.2f = %.2f",x,b);
printf("cosec %.2f = %.2f",y,a);
}
break;
case'w':
{
float a,b;
b=1/(tan(x));
a=1/(tan(y));
printf("cot %.2f = %.2f",x,b);
printf("cot %.2f = %.2f",y,a);
}
default:
line();
printf("\nInvalid Input\n");
line();
}
}
return 0;
}
#include<conio.h>
#include<math.h>
void header()
{
printf("\n");
printf("Built and Designed by Arslan-ud-Din-Shafiq\n\nReg. No .DDP-SP14-BSE-005");
printf("\n");
}
void line()
{
int i;
for(i=1;i<=48;i++)
printf("=");
}
float sum(float a,float b)
{
return a+b;
}
float subtract(float c , float d)
{
return c-d;
}
float multiply(float e,float f)
{
return e*f;
}
float divide(float g,float h)
{
return g/h;
}
int mod(int i,int j)
{
return i%j;
}
int fact(int k)
{
int i,p=1;
for(i=1;i<=k;i++)
p*=i;
return p;
}
int pwr(int n , int r)
{
int k, result=1;
for(k=1;k<=r;k++)
result*=n;
return result;
}
int main()
{
float x,y;
char m,s,c,t;
line();
header();
line();
while(m!=-1)
{
printf("\nEnter 1st Number = ");
scanf("%f",&x);
printf("\nEnter 2nd Number = ");
scanf("%f",&y);
printf("\nYou can use following Arithmatic Operations (+,-,*,^,/,%,!)\n(s) for sin \n(c)for cos \n(t) for tan \n(l) for log with base e\n(r) for square root \n(L) for log with base 10\n(z) for sec x\n(v) for cosec x\n(w) for cot x\n PRESS (e) tp END the Program = ");
m=getche();
printf("\n");
switch(m)
{
case'+':
line();
printf("\nSum of %.2f and %.2f is = %.2f\n\n",x,y,sum(x,y));
line();
break;
case'-':
line();
printf("\nSubtraction of %.2f and %.2f is = %.2f\n",x,y,subtract(x,y));
line();
break;
case'*':
line();
printf("\nProduct of %.2f and %.2f is = %.2f\n",x,y,multiply(x,y));
line();
break;
case'/':
line();
printf("\nDivision of %.2f and %.2f is = %.2f\n",x,y,divide(x,y));
line();
break;
case'%':
line();
printf("\nModulus of %d and %d is = %d\n",x,y,mod(x,y));
line();
break;
case'!':
line();
printf("\nFactorial of %d is = %d\n",x,fact(x));
line();
printf("\nFactorial of %d is = %d\n",y,fact(y));
line();
break;
case'^':
line();
printf("\n%d raised to power %d is = %d\n",x,y,pwr(x,y));
line();
break;
case'r':
line();
printf("\nSquare root of %.2f is = %.2f",x,sqrt(x));
printf("\nSquare root of %.2f is = %.2f",y,sqrt(y));
line();
break;
case's':
printf("Press (a) if 'x' is in radian or (b) if 'x' is in degrees : ");
s=getche();
printf("\n");
switch(s)
{
case'a':
line();
printf("\nsin %.1f = %.4f\n",x,sin(x));
line();
printf("\nsin %.1f = %.4f\n",y,sin(y));
line();
break;
case'b':
{ float i,j;
i=x*0.01746;
j=y*0.01746;
line();
printf("\nsin %.1f = %.4f\n",x,sin(i));
line();
printf("\nsin %.1f = %.4f\n",y,sin(j));
line();
}
break;
}
break;
case'c':
printf("Press (a) if 'x' is in radian or (b) if 'x' is in degrees : ");
c=getche();
printf("\n");
switch(c)
{
case'a':
line();
printf("\ncos %.1f = %.4f\n",x,cos(x));
line();
printf("\ncos %.1f = %.4f\n",y,cos(y));
line();
break;
case'b':
{ float i,j;
i=x*0.01746;
j=y*0.01746;
line();
printf("\ncos %.1f = %.4f\n",x,cos(i));
line();
printf("\ncos %.1f = %.4f\n",y,cos(j));
line();
}
break;
}
break;
case't':
printf("\nPress (a) if 'x' is in radian or (b) if 'x' is in degrees : ");
t=getche();
printf("\n");
switch(t)
{
case'a':
line();
printf("\ntan %.1f = %.4f\n",x,tan(x));
line();
printf("\ntan %.1f = %.4f\n",y,tan(y));
line();
break;
case'b':
{ float i,j;
i=x*0.01746;
j=y*0.01746;
line();
printf("\ntan %.1f = %.4f\n",x,tan(i));
line();
printf("\ntan %.1f = %.4f\n",y,tan(j));
line();
}
break;
}
break;
case'l':
line();
printf("\nNatural log of %.2f = %.2f \n",x,log(x));
line();
printf("\nNatural log of %.2f = %.2f \n",y,log(y));
line();
break;
case'L':
line();
printf("\nLog of %.2f with base 10 = %.2f\n",x,log10(x));
line();
printf("\nLog of %.2f with base 10 = %.2f\n",y,log10(y));
line();
break;
case'e':
{
int i;
printf("\nEnter -1 to end : ");
scanf("%d",&i);
printf("\n");
if(i==-1)
{
line();
printf("\nYou are getting out of this program.....Press Enter.\n");
line();
return 0;
}
}
break;
case'z':
{
float v,w;
v=1/(cos(x));
w=1/(cos(y));
printf("sec %.2f = %.2f",x,v);
printf("sec %.2f = %.2f",y,w);
}
break;
case'v':
{
float a,b;
b=1/(sin(x));
a=1/(sin(y));
printf("cosec %.2f = %.2f",x,b);
printf("cosec %.2f = %.2f",y,a);
}
break;
case'w':
{
float a,b;
b=1/(tan(x));
a=1/(tan(y));
printf("cot %.2f = %.2f",x,b);
printf("cot %.2f = %.2f",y,a);
}
default:
line();
printf("\nInvalid Input\n");
line();
}
}
return 0;
}