#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int a,b,i,ch;
float x,y,Ans2;
printf("\n\n\n\t\t\t*** SCIENTIFIC CALCULATOR ***");
getch();
clrscr();
do
{
printf("select the operation:\n");
printf("Press 0 for exit\n");
printf("1.Addition\n2.Subtraction\n3.Multiplication\n4.Division\n");
printf("5.square root\n6.x^2\n7.x^y\n8.x^3\n9.1/x\n10.x^(1/3)\n");
printf("11.10^x\n12.x!\n13.log10(x)\n14.e^x\n");
printf("15.sin(x)\n16.cos(x)\n17.tan(x)\n18.cosec(x)\n19.sec(x)\n20.cot(x)\n");
printf("Your choice:");
scanf("%d",&ch);
clrscr();
switch(ch)
{
case 1:
{
printf("\t\t**Addition**\n");
printf("X is:");
scanf("%f",&x);
printf("Y is:");
scanf("%f",&y);
Ans=x+y;
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 2:
{
printf("\t\t**Subtraction**\n");
printf("X is:");
scanf("%f",&x);
printf("Y is:");
scanf("%f",&y);
Ans=x-y;
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 3:
{
printf("\t\t**Multiplication**\n");
printf("X is:");
scanf("%f",&x);
printf("Y is:");
scanf("%f",&y);
Ans=x*y;
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 4:
{
printf("\t\t**Division**\n");
printf("X is:");
scanf("%f",&x);
printf("Y is:");
scanf("%f",&y);
Ans=x/y;
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 5:
{
printf("\t\t**Square root**\n");
printf("X is:");
scanf("%f",&x);
Ans=sqrt(x);
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 6:
{
printf("\t\t** x^2 **\n");
printf("X is:");
scanf("%f",&x);
Ans=pow(x,2);
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 7:
{
printf("\t\t** x^y **\n");
printf("X is:");
scanf("%f",&x);
printf("Y is:");
scanf("%f",&y);
Ans=pow(x,y);
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 8:
{
printf("\t\t** x^3 **\n");
printf("X is:");
scanf("%f",&x);
Ans=pow(x,3);
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 9:
{
printf("\t\t** 1/x **\n");
printf("X is:");
scanf("%f",&x);
Ans=1/x;
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 10:
{
printf("\t\t** x^(1/y) **\n");
printf("X is:");
scanf("%f",&x);
y=3;
Ans=pow(x,(1/y));
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 11:
{
printf("\t\t** 10^x **\n");
printf("X is:");
scanf("%f",&x);
Ans=pow(10,x);
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 12:
{
printf("\t\t** x! **\n");
printf("X is:");
scanf("%f",&x);
Ans=1;
for(i=1;i<=x;i++)
{
Ans=Ans*i;
}
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 13:
{
printf("\t\t**log10(x)**\n");
printf("X is:");
scanf("%f",&x);
Ans=log10(x);
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 14:
{
printf("\t\t** e^x **\n");
printf("X is:");
scanf("%f",&x);
Ans=exp(x);
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 15:
{
printf("\t\t**Sin(x)**\n");
printf("X is:");
scanf("%f",&x);
Ans=sin(x);
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 16:
{
printf("\t\t**cos(x)**\n");
printf("X is:");
scanf("%f",&x);
Ans=cos(x);
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 17:
{
printf("\t\t**tan(x)**\n");
printf("X is:");
scanf("%f",&x);
Ans=tan(x);
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 18:
{
printf("\t\t**cosec(x)**\n");
printf("X is:");
scanf("%f",&x);
Ans=1/(sin(x));
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 19:
{
printf("\t\t**Sec(x)**\n");
printf("X is:");
scanf("%f",&x);
Ans=1/(cos(x));
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 20:
{
printf("\t\t**cot(x)**\n");
printf("X is:");
scanf("%f",&x);
Ans=1/(tan(x));
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
}
}
while(ch!=0);
getch();
}
You can add more operations in this project.
For any query feel free to write us.
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int a,b,i,ch;
float x,y,Ans2;
printf("\n\n\n\t\t\t*** SCIENTIFIC CALCULATOR ***");
getch();
clrscr();
do
{
printf("select the operation:\n");
printf("Press 0 for exit\n");
printf("1.Addition\n2.Subtraction\n3.Multiplication\n4.Division\n");
printf("5.square root\n6.x^2\n7.x^y\n8.x^3\n9.1/x\n10.x^(1/3)\n");
printf("11.10^x\n12.x!\n13.log10(x)\n14.e^x\n");
printf("15.sin(x)\n16.cos(x)\n17.tan(x)\n18.cosec(x)\n19.sec(x)\n20.cot(x)\n");
printf("Your choice:");
scanf("%d",&ch);
clrscr();
switch(ch)
{
case 1:
{
printf("\t\t**Addition**\n");
printf("X is:");
scanf("%f",&x);
printf("Y is:");
scanf("%f",&y);
Ans=x+y;
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 2:
{
printf("\t\t**Subtraction**\n");
printf("X is:");
scanf("%f",&x);
printf("Y is:");
scanf("%f",&y);
Ans=x-y;
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 3:
{
printf("\t\t**Multiplication**\n");
printf("X is:");
scanf("%f",&x);
printf("Y is:");
scanf("%f",&y);
Ans=x*y;
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 4:
{
printf("\t\t**Division**\n");
printf("X is:");
scanf("%f",&x);
printf("Y is:");
scanf("%f",&y);
Ans=x/y;
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 5:
{
printf("\t\t**Square root**\n");
printf("X is:");
scanf("%f",&x);
Ans=sqrt(x);
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 6:
{
printf("\t\t** x^2 **\n");
printf("X is:");
scanf("%f",&x);
Ans=pow(x,2);
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 7:
{
printf("\t\t** x^y **\n");
printf("X is:");
scanf("%f",&x);
printf("Y is:");
scanf("%f",&y);
Ans=pow(x,y);
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 8:
{
printf("\t\t** x^3 **\n");
printf("X is:");
scanf("%f",&x);
Ans=pow(x,3);
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 9:
{
printf("\t\t** 1/x **\n");
printf("X is:");
scanf("%f",&x);
Ans=1/x;
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 10:
{
printf("\t\t** x^(1/y) **\n");
printf("X is:");
scanf("%f",&x);
y=3;
Ans=pow(x,(1/y));
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 11:
{
printf("\t\t** 10^x **\n");
printf("X is:");
scanf("%f",&x);
Ans=pow(10,x);
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 12:
{
printf("\t\t** x! **\n");
printf("X is:");
scanf("%f",&x);
Ans=1;
for(i=1;i<=x;i++)
{
Ans=Ans*i;
}
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 13:
{
printf("\t\t**log10(x)**\n");
printf("X is:");
scanf("%f",&x);
Ans=log10(x);
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 14:
{
printf("\t\t** e^x **\n");
printf("X is:");
scanf("%f",&x);
Ans=exp(x);
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 15:
{
printf("\t\t**Sin(x)**\n");
printf("X is:");
scanf("%f",&x);
Ans=sin(x);
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 16:
{
printf("\t\t**cos(x)**\n");
printf("X is:");
scanf("%f",&x);
Ans=cos(x);
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 17:
{
printf("\t\t**tan(x)**\n");
printf("X is:");
scanf("%f",&x);
Ans=tan(x);
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 18:
{
printf("\t\t**cosec(x)**\n");
printf("X is:");
scanf("%f",&x);
Ans=1/(sin(x));
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 19:
{
printf("\t\t**Sec(x)**\n");
printf("X is:");
scanf("%f",&x);
Ans=1/(cos(x));
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
case 20:
{
printf("\t\t**cot(x)**\n");
printf("X is:");
scanf("%f",&x);
Ans=1/(tan(x));
printf("Ans is=%f",Ans);
getch();
clrscr();
}break;
}
}
while(ch!=0);
getch();
}
You can add more operations in this project.
For any query feel free to write us.