The program doesn't run although it is compiled

#include <iostream.h>
#include <math.h>
#include <conio.h>
void main()
{ //this program calculates any expression you want
cout<<"if you want to calculate any expression including + - * / press A \n";
cout<<"if you want to calculate the square root of a number press B\n";
cout<<"if you want to calculate the square of a number press C\n";
cout<<"if you want to calculate the cube of a number press D\n";
cout<<"if you want to calculate the sin of a number press E\n";
cout<<"if you want to calculate the cos of a number press F\n";
cout<<"if you want to calculate the tan of a number press G\n";
getch();
int a,b,n,e,f,g,h,i;
char op;
char choice;
if (choice=='A')
{
cout<<"please enter the operator you want";
if (op=='+')
{
cin>>a>>b;
cout<<"a+b="<<(a+b);
}
else if(op=='-')
{
cin>>a>>b;
cout<<"a-b="<<(a-b);
}
else if(op=='*')
{
cin>>a>>b;
cout<<"a*b="<<(a*b);
}
else if(op=='/')
{
cin>>a>>b;
cout<<"a/b"<<(a/b);
}
}
if (choice=='B')
{
cin>>n;
cout<<"the square root of "<<n<<"is "<<sqrt(n);
}
if (choice=='C')
{
cin>>e;
cout<<"the square of "<<e<<"is "<<e*e;
}
if (choice=='D')
{
cin>>f;
cout<<"the cube of "<<f<<"is "<<f*f*f;
}
if (choice=='E')
{
cin>>g;
cout<<"the sin of "<<g<<"is "<<sin(g);
}
if (choice=='F')
{
cin>>h;
cout<<"the cos of "<<h<<"is "<<cos(h);
}
if (choice=='G')
{
cin>>i;
cout<<"the tan of "<<i<<"is "<<tan(i);
}
getch();
}
closed account (z05DSL3A)
1
2
3
4
5
...
char choice;
// need user input for choice!!
if (choice=='A')
...


There are a number of areas that you need to get user input.
Thanks for your help Grey Wolf.It was useful to me.
Last edited on
Topic archived. No new replies allowed.