how do i fix this error??

all of the underlined peices of code say this"expected ; before string constant"
how do i fix that -thanks,moot

using namespace std;

int main(){

char cchar;
double dnumber1;
double dnumber2;

do{
cout << "please enter the first number you would like to use" << endl;
cin >> dnumber1;
cout << "please enter the operation you would like to use, +,-,*, or /";
cout << endl;
cin >> cchar;
cout << "please enter the second number you would like to use" << endl;
cin >> dnumber2;


switch (cchar){
case '+':
cout << "the answer is: " << dnumber1 " + " << dnumber2 " = "
<< (dnumber1 + dnumber2) << endl;
break;
case '-':
cout << "the answer is: " << dnumber1 " - " << dnumber2 " = "
<< (dnumber1 - dnumber2) << endl;
break;
case '*':
cout << "the answer is: " << dnumber1 " * " << dnumber2 " = "
<< (dnumber1 * dnumber2) << endl;
break;
case '/':
cout << "the answer is: " << dnumber1 " / " << dnumber2 " = "
<< (dnumber1 / dnumber2) << endl;
break;
}
system("pause");
return 0;
}
cout << "the answer is: " << dnumber1 " + " << dnumber2 " = "
should be
cout << "the answer is: " << dnumber1 << " + " << dnumber2 <<" = "

Likewise other lines.
You cannot output a variable and a string "at the same time". It has to be separate.

You are doing:

cout << variable "constant string" << variable "constant string"

The proper syntax is

cout << variable << "constant string" << variable << "constant string"
ok thx for the help
ok now all of the errors are on the last line, the underlined 1
and where do i put a "}" for the do statement


int main(){

char cchar;
double dnumber1;
double dnumber2;

do{
cout << "please enter the first number you would like to use" << endl;
cin >> dnumber1;
cout << "please enter the operation you would like to use, +,-,*, or /";
cout << endl;
cin >> cchar;
cout << "please enter the second number you would like to use" << endl;
cin >> dnumber2;



switch (cchar){
case '+':
cout << "the answer is: " << dnumber1 << " + " << dnumber2 << " = "
<< (dnumber1 + dnumber2) << endl;
break;
case '-':
cout << "the answer is: " << dnumber1 << " - " << dnumber2 << " = "
<< (dnumber1 - dnumber2) << endl;
break;
case '*':
cout << "the answer is: " << dnumber1 << " * " << dnumber2 << " = "
<< (dnumber1 * dnumber2) << endl;
break;
case '/':
cout << "the answer is: " << dnumber1 << " / " << dnumber2 << " = "
<< (dnumber1 / dnumber2) << endl;
break;
}
system("pause");
return 0;
}
Where's the while that goes with the do?
ok now the error is on the underlined sentence, the error is non l-value in assignment

#include <iostream>

using namespace std;

int main(){

char cchar;
double dnumber1;
double dnumber2;
char cagain;

do{

system("CLS");
cout << "please enter the first number you would like to use" << endl;
cin >> dnumber1;
cout << "please enter the operation you would like to use, +,-,*, or /";
cout << endl;
cin >> cchar;
cout << "please enter the second number you would like to use" << endl;
cin >> dnumber2;



switch (cchar){
case '+':
cout << "the answer is: " << dnumber1 << " + " << dnumber2 << " = "
<< (dnumber1 + dnumber2) << endl;
break;
case '-':
cout << "the answer is: " << dnumber1 << " - " << dnumber2 << " = "
<< (dnumber1 - dnumber2) << endl;
break;
case '*':
cout << "the answer is: " << dnumber1 << " * " << dnumber2 << " = "
<< (dnumber1 * dnumber2) << endl;
break;
case '/':
cout << "the answer is: " << dnumber1 << " / " << dnumber2 << " = "
<< (dnumber1 / dnumber2) << endl;
break;
}

cout << "would you like to start again (y or n)";
cin >> cagain;
}while (cagain = 'y' || cagain = 'Y');

system("pause");
return 0;
}
Did you mean == ?
yes thank you and i sent you a privite message can u answer it
I don't answer private messages that should be public questions. Just ask in the forum.
i did its on the first page but noone answered
its on the first page
Topic archived. No new replies allowed.