hi.
i m a new c++ programmer but i have been already programmed vb applications b4...
now i m making a very simple calculator to pracice a bit and i need help.
the calculator works like that:
you enter a number
you select an action
you enter another number
you get the resualt
very very simple as you can c...
now my problem is that you can c the resualt for 1sec. only and the program is quiting tought i used the command system("PAUSE");...
here is the source code:
Code:
#include <iostream.h>
int main()
{
float fnum;
float snum;
int action;
float a;
cout<<"Enter the first number:"<<endl;
cin>>fnum;
cout<<"Select the action:"<<endl;
cout<<"1. Add (+)"<<endl;
cout<<"2. Substract (-)"<<endl;
cout<<"3. Multipyle (*)"<<endl;
cout<<"4. Divide (/)"<<endl;
cin>>action;
cout<<"Enter the second number:"<<endl;
cin>>snum;
if(action==1)
{
a=fnum+snum;
cout<<"The resualt is: "<<a;
}
else if(action==2)
{
a=fnum-snum;
cout<<"The resualt is: "<<a;
}
else if(action==3)
{
a=fnum*snum;
cout<<"The resualt is: "<<a;
}
else if(action==4)
{
a=fnum/snum;
cout<<"The resualt is: "<<a;
}
else
{
cout<<"Inviled command."<<endl<<"Quiting program now.";
}
system("PAUSE");
return 0;
}
can some1 help me here plz?