Scientific Calculator Menu Base

Write a program in c++ in menu base scientific calculator using math library :

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.14159265

void add();
void sub();
void multi();
void div();
void fact();
void mode();// %
int facto(int);
void trigno();
void power();
void square();
void abc();  //absolute
void ceilv(); //upper limit
void floorv(); //lower limit
void logn();



//main function..
void main()
{
start:
int no,fc;
clrscr();
cout<<"***********************Secientific caculator********************"<<endl;
cout<<" Enter the Operator"<<endl;
cout<<" 1-Addition\n 2-subtraction\n 3-Multilpication\n 4-division\n 5-Factorial\n 6-Mode\n 7-Permutation\n 8-Square\n 9-Absulate\n 10-Trinometery\n 11-power\n 12-Ceil\n 13-floor\n 14-Log\n 15-Exit"<<endl;
cin>>no;
if(no==1)
{
add();
}
else if(no==2)
{
sub();
}
else if(no==3)
{
multi();
}
else if(no==4)
{
div();
}
else if(no==5)
{
fact();
}
else if(no==6)
{
mode();
}
else if(no==7)
{
int n,r,nPr;

       cout<<"Enter n: ";
       cin>>n;

       cout<<"Enter r: ";
       cin>>r;

       nPr=facto(n)/facto(n-r);
       cout<<" Answer:"<<nPr<<endl;
       system("pause");
}
else if(no==10)
  {
  trigno();
  }
  else if(no==11)
  {
  power();
  }
  else if(no==8)
  {
 square();
  }
  else if(no==9)
  {
abc();
}
else if(no==12)
{
ceilv();
}
else if(no==13)
{
 floorv();
}
else if(no==14)
{

 logn();
}
else if(no==15)
{
 exit(0);
}
else
{
cout<<"invalid number";
}
goto start;
getch();
}
void add()
{
int x,y;
cout<<"enter first number"<<endl;
cin>>x;
cout<<"enter second number"<<endl;
cin>>y;
cout<<"\tAnswer:"<<x+y<<endl;
system("pause");
}
void sub()
{
int x,y;
cout<<"enter number frist number"<<endl;
cin>>x;
cout<<"enter second number"<<endl;
cin>>y;
cout<<"\tAnswer:"<<x-y<<endl;
system("pause");
}
void multi()
{
int x,y;
cout<<"enter first number"<<endl;
cin>>x;
cout<<"enter second number"<<endl;
cin>>y;
cout<<"\tAnswer:"<<x*y<<endl;
system("pause");

}
void div()
{
int x,y;
cout<<"enter first number"<<endl;
cin>>x;
cout<<"enter second number"<<endl;
cin>>y;
cout<<"\tAnswer:"<<x/y<<endl;
system("pause");
}
void fact()
{
long fact=1;
int n;

cout<<"Enter Factorial number"<<endl;
cin>>n;
     for(int i=1;i<=n;i++)
    {
       fact=fact*i;
     }

   cout<<"Factorrial is:"<<fact<<endl;
       system("pause");
}
int facto(int num){


if(num==1)
{
     return 1;
}
else
{
    return num * facto(num-1);
}

//system("pause");
}
void mode(){
int x,y;
   cout<<"Enter first value of mode"<<endl;
   cin>>x;
   cout<<"Enter second  value of mode"<<endl;
   cin>>y;
   cout<<"\tAnswer:"<<x%y<<endl;
   system("pause");
}
void trigno()
{
int s;
float angle;
do{
cout<<"Slect Trignometery function\n 1-sin@\n 2-cos@\n 3-tan@\n 4-sine@\n 5-cosine@\n 6-tangent@\n 7-For man menu\n"<<endl;
cin>>s;
if(s==1)
{

  cout<<"Enter the radian of angle"<<endl;
  cin>>angle;
  cout<<"\tAnswer:"<<sin(angle*PI/180)<<endl;
}
if(s==2)
{

  cout<<"Enter the radian of angle"<<endl;
  cin>>angle;
  cout<<"\tAnswer:"<<cos(angle*PI/180)<<endl;
}
if(s==3)
{
   cout<<"Enter the radian of angle"<<endl;
   cin>>angle;
   cout<<"\tAnswer:"<<tan(angle*PI/180)<<endl;
}
if(s==4)
{
  cout<<"Enter the radian of angle"<<endl;
  cin>>angle;
  cout<<"\tAnswer:"<<asin(angle)*180.0/PI<<endl;
}

if(s==5)
{
  cout<<"Enter the radian of angle"<<endl;
  cin>>angle;
  cout<<"\tAnswer:"<<acos(angle)*180.0/PI<<endl;
}
if(s==6)
{
  cout<<"Enter the radian of angle"<<endl;
  cin>>angle;
  cout<<"\tAnswer:"<<atan(angle)*180.0/PI<<endl;
}
}while(s!=7);
system("pause");
}
void power(){
int pw,tme;
cout<<"Enetr the value of power"<<endl;
cin>>pw;
cout<<"How times"<<endl;
cin>>tme;
cout<<"\tAnser is:"<<pow(pw,tme)<<endl;
system("pause");

}
void square(){
int sqr;
   cout<<"enter the value of square"<<endl;
   cin>>sqr;
   cout<<"Answer :"<<sqr*sqr<<endl;
   system("pause");

}
void abc(){
int ab;
  cout<<"Enter the absolute value"<<endl;
  cin>>ab;
  cout<<"Answer:"<<abs(ab)<<endl;
  system("pause");
}
void ceilv(){
int cel;
cout<<"Enter the Ceil value"<<endl;
cin>>cel;
cout<<"Answer:"<<cel<<ceil(cel)<<endl;
system("pause");
}
void floorv(){
   int fld;
   cout<<"Enter the flood value"<<endl;
   cin>>fld;
   cout<<"Answer:"<<floor(fld)<<endl;
   system("pause");

}
void logn(){
int no,st;
do{
cout<<"slect log\n 1-log\n 2-log10\n 3-For man menun\n";
cin>>st;
if(st==1)
{
cout<<"enter log value"<<endl;
cin>>no;
cout<<"Answer: "<<log(no)<<endl;
system("pause");
}
if(st==2)
{
cout<<"enter log10 value"<<endl;
cin>>no;
cout<<"Answer: "<<log10(no)<<endl;
system("pause");

}
}while(st!=3);}

Output

















No comments:

Post a Comment