include <iostream>
using namespace std;
int z;
int x;
int main ()
{
char b;
char z;
int x;
int y;
int a;
calculation:
cout << "hi\n";
cout << "please input a number\n";
cin>>x;
cout<<"please input enougher number\n";
cin>>y;
cout<< "please input sign of operation\n";
cin>>z;
if(z==+)
{
a = (x + y);
}
else if (z==-)
{
a = (x - y);
}
else if (z==/)
{
a = ( x / y);
}
else if (z==*)
{
a = ( x/ y);
}
else
{
cout<<"not a valid operation sign\n";
}
cout<<a<<"/n";
cout<<"do you want to make enougher calculaton? y/n\n";
cin>>b;
if (b==y)
{
goto calculations;
}
else
{
return 0;
}
}
i am a c++ begginer trying to make a calculator program. these are the errors i am getting. all the websites i have looked at do not put a semicolon after the ) it wants me to and i have tried building it with the colons getting rid if those errors but the others remain. i also can not figure out why the / is making an error. Is something wrong with my else if statements? All my else statements are meant to be else statements.
1>c:\users\eric\documents\visual studio 2008\projects\test\test\1st.cpp(23) : error C2059: syntax error : ')'
1>c:\users\eric\documents\visual studio 2008\projects\test\test\1st.cpp(24) : error C2143: syntax error : missing ';' before '{'
1>c:\users\eric\documents\visual studio 2008\projects\test\test\1st.cpp(27) : error C2181: illegal else without matching if
1>c:\users\eric\documents\visual studio 2008\projects\test\test\1st.cpp(27) : error C2059: syntax error : ')'
1>c:\users\eric\documents\visual studio 2008\projects\test\test\1st.cpp(28) : error C2143: syntax error : missing ';' before '{'
1>c:\users\eric\documents\visual studio 2008\projects\test\test\1st.cpp(31) : error C2181: illegal else without matching if
1>c:\users\eric\documents\visual studio 2008\projects\test\test\1st.cpp(31) : error C2059: syntax error : '/'
1>c:\users\eric\documents\visual studio 2008\projects\test\test\1st.cpp(32) : error C2143: syntax error : missing ';' before '{'
1>c:\users\eric\documents\visual studio 2008\projects\test\test\1st.cpp(35) : error C2181: illegal else without matching if
1>c:\users\eric\documents\visual studio 2008\projects\test\test\1st.cpp(35) : error C2059: syntax error : ')'
1>c:\users\eric\documents\visual studio 2008\projects\test\test\1st.cpp(36) : error C2143: syntax error : missing ';' before '{'
1>c:\users\eric\documents\visual studio 2008\projects\test\test\1st.cpp(39) : error C2181: illegal else without matching if
using namespace std;
int z;
int x;
int main ()
{
char b;
char z;
int x;
int y;
int a;
calculation:
cout << "hi\n";
cout << "please input a number\n";
cin>>x;
cout<<"please input enougher number\n";
cin>>y;
cout<< "please input sign of operation\n";
cin>>z;
if(z==+)
{
a = (x + y);
}
else if (z==-)
{
a = (x - y);
}
else if (z==/)
{
a = ( x / y);
}
else if (z==*)
{
a = ( x/ y);
}
else
{
cout<<"not a valid operation sign\n";
}
cout<<a<<"/n";
cout<<"do you want to make enougher calculaton? y/n\n";
cin>>b;
if (b==y)
{
goto calculations;
}
else
{
return 0;
}
}
i am a c++ begginer trying to make a calculator program. these are the errors i am getting. all the websites i have looked at do not put a semicolon after the ) it wants me to and i have tried building it with the colons getting rid if those errors but the others remain. i also can not figure out why the / is making an error. Is something wrong with my else if statements? All my else statements are meant to be else statements.
1>c:\users\eric\documents\visual studio 2008\projects\test\test\1st.cpp(23) : error C2059: syntax error : ')'
1>c:\users\eric\documents\visual studio 2008\projects\test\test\1st.cpp(24) : error C2143: syntax error : missing ';' before '{'
1>c:\users\eric\documents\visual studio 2008\projects\test\test\1st.cpp(27) : error C2181: illegal else without matching if
1>c:\users\eric\documents\visual studio 2008\projects\test\test\1st.cpp(27) : error C2059: syntax error : ')'
1>c:\users\eric\documents\visual studio 2008\projects\test\test\1st.cpp(28) : error C2143: syntax error : missing ';' before '{'
1>c:\users\eric\documents\visual studio 2008\projects\test\test\1st.cpp(31) : error C2181: illegal else without matching if
1>c:\users\eric\documents\visual studio 2008\projects\test\test\1st.cpp(31) : error C2059: syntax error : '/'
1>c:\users\eric\documents\visual studio 2008\projects\test\test\1st.cpp(32) : error C2143: syntax error : missing ';' before '{'
1>c:\users\eric\documents\visual studio 2008\projects\test\test\1st.cpp(35) : error C2181: illegal else without matching if
1>c:\users\eric\documents\visual studio 2008\projects\test\test\1st.cpp(35) : error C2059: syntax error : ')'
1>c:\users\eric\documents\visual studio 2008\projects\test\test\1st.cpp(36) : error C2143: syntax error : missing ';' before '{'
1>c:\users\eric\documents\visual studio 2008\projects\test\test\1st.cpp(39) : error C2181: illegal else without matching if
Last edited: