Hello today I wanted to make a simple calculator and understand how it works
and here's what I got so far but I can't get it to restart itself when I press
one key.
The Code so far is :
include <iostream>
using namespace std;
int main()
{
char rept;
do
{
int a;
int b;
int sum;
cin >> a;
cin >> b;
sum = a*b;
cout << "Awnser: " << sum << endl;
cout << "The answer is solved by Vincent Dominguez your awnser correct. "<<
endl;
cin >> rept;
while (rept == 'y' || rept == 'Y');
return 0;
}
Then I get a error at the } end.
can someone tell me how to fix this and explain it to me thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Just do what compiler says to you. You missed an }. you must to find out
where.. Its really easy to find it. I'm not going to tell you... I just tell
you that if you open an { some where you must close it with an }
One trick to help you avoid this kind of errors is to write your code like
this
Its better to use mean full variables like: sum = a + b and product = a * b.
In programs like this its not easy to notice how much useful is, but in a
program of 2000 lines (a student program) is very useful.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello today I wanted to make a simple calculator and understand how it works
and here's what I got so far but I can't get it to restart itself when I press
one key.
The Code so far is :
include <iostream>
using namespace std;
int main()
{
char rept;
do
{
int a;
int b;
int sum;
cin >> a;
cin >> b;
sum = a*b;
cout << "Awnser: " << sum << endl;
cout << "The answer is solved by Vincent Dominguez your awnser correct. "<<
endl;
cin >> rept;
while (rept == 'y' || rept == 'Y');
return 0;
}
Then I get a error at the } end.
can someone tell me how to fix this and explain it to me thanks.
Just do what compiler says to you. You missed an }. you must to find out
where.. Its really easy to find it. I'm not going to tell you... I just tell
you that if you open an { some where you must close it with an }
One trick to help you avoid this kind of errors is to write your code like
this
Its better to use mean full variables like: sum = a + b and product = a * b.
In programs like this its not easy to notice how much useful is, but in a
program of 2000 lines (a student program) is very useful.