1. Sep 5, 2010

### ihatecats2014

1. The problem statement, all variables and given/known data

#include <iostream>
using namespace std;

int main()
{

int firstNo;// first number is stored here
int secondNo,
int resultAdd,// variable for result when first number and second number are added
int resultSub,// variable for result when first number and second number are subtracted
int resultMult,// variable for result when first number and second number are multiplied
int resultDivi// variable for the reult when the first number and second number are divided
;

// asks the user to choose the first number
cout<< "Enter in the first Number -> /n";
cin >> "firstNo";

// asks the user for the second number
cout<< "Enter in the second Number -> ";
cin >> "secondNo";

cout<< "which operation would you like to choose?";

// result of the operation when addition is chosen
cout<< "the sum of the numbers are ->/n";

// result of the operation when subtraction is chosen
resultSub = firstNo - secondNo;
cout<< "the difference of these numbers are ->/n";
cin >> "resultSub";

// result of the operation when multiplication is chosen
resultMult == firstNo * secondNo;
cout<< "the product of these numbers are ->/n";
cin >> "resultMult";

// result of the operation when division is chosen
resultDivi == firstNo/seconNo;
cout<< "the quotient of these two numbers are ->/n";
cin >> "resultDivi"

;if (secondNo == 0 )// restriction put upon operation so that denominator cannot be 0
firstNo/secondNo !==0;
cout<< "the quotient of these two numbers are undefined :(";

cout<<"/n";

return 0;

}

i don't know what i did wrong, but i guess i did alot wrong, i just basically followed the template that my professor showed us, but the program he made just had one operation and that was addition.

it went like this:
Result = FirstNo + SecondNo;

cout<< "these numbers add up to ->";
cout<< Result;

so i figured i could just make more than one variable and define them with operations.

Last edited: Sep 5, 2010
2. Sep 5, 2010

### ihatecats2014

error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'const char [8]' (or there is no acceptable conversion)
error C2059: syntax error : '='
error C2062: type 'int' unexpected

are some error statements

Last edited: Sep 5, 2010
3. Sep 5, 2010

### Staff: Mentor

The first declaration above is fine, but each of the next four has an error. To the compiler, these look like separate declarations, because each line starts with int, but don't end with a semicolon. In C and C++ and other C-like languages, all statements end with semicolons.

You can declare secondNo, resultAdd, resultSub, resultMult, and resultDivi in one declaration like this
int secondNo, resultAdd, resultSub, resultMult, and resultDivi;

Or you can declare them in separation declarations like this
int secondNo;
int resultSub;
int resultMult;
int resultDivi;

You need a variable, not a string literal. Presumably this is why you declared firstNo. Similar comment on the next two groups of statements.
The statement above is doing something, but not what you intended. It adds firstNo and secondNo, and determines whether this value is equal to the value in resultAdd. The result will be a binary value that will be discarded since it's not being saved to a variable.

Use the assignment operator.
There are two things wrong above. One, you should be using a variable with cin. Two, you should not ask for the sum of the numbers as input from the user. Your program already calculated it. Instead of doing input, your program should output the calculated result. This latter error is not a compiler (or syntax) error - it is a semantic error.
Similar comment as before. The program should not be doing input; it should be displaying the calculated result. Similar comment in the next two blocks of code.
What do you think this is doing?

4. Sep 5, 2010

### ihatecats2014

i got it to work, but it is not doing what i want it to do. it works fine when i ask the user for two numbers it goes like this:
Enter the first number->45
Enter the second number->5
what operator would you like to use? the sum of the number is 50/n->
after you plug in any other operator sign it will output all the remaining operations:

here is my new code:

#include <iostream>
using namespace std;

int main()
{

int firstNo;// first number is stored here
int secondNo;
int resultSub;//variable for result when first and second number are subtracted
int resultMult;//variable for result when first and second number are multiplied
int resultDivi//variable for result when first and second number are divided
;

// asks the user to choose the first number
cout<< "Enter in the first Number ->";
cin >> firstNo;

// asks the user for the second number
cout<< "Enter in the second Number -> ";
cin >> secondNo;

cout<< "which operation would you like to choose?";

// result of the operation when addition is chosen
cout<< "the sum of the numbers are ->" <<resultAdd << "/n";

// result of the operation when subtraction is chosen
resultSub = firstNo - secondNo;
cout<< "the difference of these numbers are ->" <<resultSub<< "/n";

// result of the operation when multiplication is chosen
resultMult = firstNo * secondNo;
cout<< "the product of these numbers are ->" <<resultMult<< "/n";

// result of the operation when division is chosen
resultDivi = firstNo/secondNo;
cout<< "the quotient of these two numbers are ->/n"<<resultMult<< "/n";

if(secondNo = 0)// restriction put upon operation so that denominator cannot be 0

cout<< "the quotient of these two numbers are undefined ";

cout<<"/n";

return 0;

}
btw i am using windows visual studio c++
can you try compiling it and see if the same thing happens on your computer?

5. Sep 6, 2010