Newbie help

• 04-26-2012
Newbie help
Hey All,

I recently started Learning c++. I have purchased Jumping into c++ (and c++ for Dummies)and have a couple of Questions.

1. Are there answers for the Practice Problems anywhere from Jumping into C++

2. Also Having an issue with one of the Problems: The program runs but doesn't give me the result. Any thoughts?

Code:

```#include <iostream> #include <cstdio> #include <cstdlib> using namespace std; int Addition(int Num1, int Num2) {     int Ans = Num1 + Num2;     return Ans; } int Subtraction(int Num1, int Num2) {     int Ans = Num1 - Num2;     return Ans; } int Multiplication(int Num1, int Num2) {     int Ans = Num1 * Num2;     return Ans; } int Division(int Num1, int Num2) {     int Ans = Num1 / Num2;     return Ans; } int main() {     int nAns; //For Loop Version of Program     int nNum1;     int nNum2;     char cOperand;     cout << "Please enter the First Number: ";     cin >> nNum1;     cout << "\nPlease enter the Second Number: ";     cin >> nNum2;     cout << "\nPlease enter your Operator as + - /  * %: ";     cin >> cOperand;     //cout << "The Answer is: " << ans << "\n";     switch (cOperand)     {         case '+':         nAns = Addition(nNum1, nNum2);         return nAns;         break;         case '-':         nAns = Subtraction(nNum1, nNum2);         return nAns;         break;         case '*':         case 'x':         case 'X':         nAns = Multiplication(nNum1, nNum2);         return nAns;         break;         case '/':         nAns = Division(nNum1, nNum2);         return nAns;         break;         default:         cout << "Invalid Operator!";         break;     }     cin.ignore();     cout << "The Answer is: " << nAns; }```
Thanks for any help :)

Edit: It actually looks to be getting the correct answer as when I run the program in Code:Blocks it exits and says: Process returned 10 (0xA). Its just not giving me the output of the answer.
• 04-26-2012
ZuK
remove all the
Code:

`    return nAns;`
returning from main will terminate the program and your output statements will never be reached.
Kurt
• 04-26-2012
`    return nAns;`