hi guys, im trying to get a program that requires a input of numbers and add them up, requiring the user to supply number each time using a do loop, ive done what i think is correct but i keep getting these errors:
(6) : error C2059: syntax error : 'do'
(8) : error C2143: syntax error : missing ';' before '{'
(8) : error C2447: '{' : missing function header (old-style formal list?)
here is my code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <iostream>
usingnamespace std;
int main ();
int total, number;
char answer;
do;
{
cout << "input a number" <<endl;
cin >> number;
total = total + number
cout << "any more?"<<endl;
cin >> answer;
while (reply != ‘n’)
cout << total;
}
I said you should add an opening bracket on line 6. That wasn't really true. What I meant to say was that you should add an closing bracket on line 13 before while.
Im very confused, so this is what ur asking me to do?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <iostream>
usingnamespace std;
int main (){
int total, number;
char answer;
do
{
cout << "input a number" <<endl;
cin >> number;
total = total + number
cout << "any more?"<<endl;
cin >> answer;
}
while (reply != ‘n’);
cout << total;
}
I don't know. You probably want to do more than that, otherwise your code will never end. Maybe you want reply to be the same as answer? In that case just remove reply and replace it with answer on line 16.