#include<iostream>
using namespace std;
int main()
{
int i;
double oper[i],ans;
char operation;
string tryagain;
cout<<"Simple Calculator [v. Beginnercode]"<<endl;
tryagain='y';
while(tryagain=="y"||tryagain=="Y")
{
cout<<endl<<"SYNTAX: [NUM_1] [OPERATOR] [NUM_2]:";
for(i=0;i<3;i++)
{
if(i==0||i==2)
{
cout<<" ";cin>>oper[i];
}
else
cin>>operation;
}
switch (operation)
{
case '+':
ans=oper[0]+oper[2];break;
case '-':
ans=oper[0]-oper[2];break;
case '*':
ans=oper[0]*oper[2];break;
case '/':
ans=oper[0]/oper[2];break;
case '=':
ans=oper[0];break;
default:
cout<<"SYNTAX ERROR!!! UNDEFINED OPERATION (wrong result)";
}
cout<<" = "<<ans<<endl;
cout<<endl<<"Want to try again (y/n)? ";cin>>tryagain;
}
cout<<endl<<"THANK YOU! ";
system("pause");
return 0;
}
Okay, what's wrong with it?
And use [code][/code] tag, please.