C
Christo
borland c++ 5.01
character constant must be one or two characters long
get this when compiling my first c++ program can anyone out there help?
it is highlighting this line as the problem
cout << "Please Enter First number: ";
that is correct isnt it though?
here is the code i have used...
#include <iostream.h>
void main (void)
{
int iFirst, iSecond, iAnswer;
char cOperator, cCmd;
cout << endl;
cout << endl;
cout << "Press any key to start the program or type help to view help: ";
cin >> cCmd; endl;
if (cCmd == 'help')
cout << "Help File" endl;
cout << endl;
cout << "Using this calculator is simple below is the key for the
operators"; endl;
cout << "+ = Add \n - = Subtract \n / = Divide \n * = Multiply";
cout << endl;
cout << "Please restart to program to continue"; endl;
else
cout << "Please select which operator would would like to use +/-: ";
cin >> cOperator; endl;
cout << "Please Enter First number: ";
cin >> iFirst; endl;
cout << "Please Enter Second Number: ";
cin >> iSecond;
if (cOperator == '+')
iAnswer = iFirst+iSecond;
else if
(cOperator == '/')
iAnswer = iFirst/iSecond;
else if
(cOperator == '-')
iAnswer = iFirst-iSecond;
else if
(cOperator == '*')
iAnswer = iFirst*iSecond;
else
cout << endl;
cout << "****Please Input A Correct Operator****" endl;
cout << "The Answer To your Sum is: ";
cout << iAnswer;
}
i know it is probably not the easiest way to create a simple calculator but
i know this way will work but i dont know what is casusing the failure when
i try to compile
any help would be much appreciated
character constant must be one or two characters long
get this when compiling my first c++ program can anyone out there help?
it is highlighting this line as the problem
cout << "Please Enter First number: ";
that is correct isnt it though?
here is the code i have used...
#include <iostream.h>
void main (void)
{
int iFirst, iSecond, iAnswer;
char cOperator, cCmd;
cout << endl;
cout << endl;
cout << "Press any key to start the program or type help to view help: ";
cin >> cCmd; endl;
if (cCmd == 'help')
cout << "Help File" endl;
cout << endl;
cout << "Using this calculator is simple below is the key for the
operators"; endl;
cout << "+ = Add \n - = Subtract \n / = Divide \n * = Multiply";
cout << endl;
cout << "Please restart to program to continue"; endl;
else
cout << "Please select which operator would would like to use +/-: ";
cin >> cOperator; endl;
cout << "Please Enter First number: ";
cin >> iFirst; endl;
cout << "Please Enter Second Number: ";
cin >> iSecond;
if (cOperator == '+')
iAnswer = iFirst+iSecond;
else if
(cOperator == '/')
iAnswer = iFirst/iSecond;
else if
(cOperator == '-')
iAnswer = iFirst-iSecond;
else if
(cOperator == '*')
iAnswer = iFirst*iSecond;
else
cout << endl;
cout << "****Please Input A Correct Operator****" endl;
cout << "The Answer To your Sum is: ";
cout << iAnswer;
}
i know it is probably not the easiest way to create a simple calculator but
i know this way will work but i dont know what is casusing the failure when
i try to compile
any help would be much appreciated