   Nooblet code
  Hello!I have been lurking this site for a bit now, contemplating learning a programming language.  I decided on C++, and bought a book yesterday like I see a lot of people recommend.I bought C++ for dummies all in one by Jeff Cogswell.  Seven mini-books in one that goes over everything it seems.I started it last night and today and I decided to take a few of the things I have learned so far and make a useless... but functional calculator in the console window.I was trying to use functions and loops and all that, so I'm sure it could be smaller and better looking heheh.  But what my question is, is with the else if loops.  It just doesnt seem like the right way to do menu selection.  Maybe I need to go further in the book, or maybe it's right.  I'm not sure.Even though I just officially registered I would like to thank you guys that I see in this forum a lot.  Made me less worried about asking here.#include <cstdlib>#include <iostream>using namespace std;//function for the different maths.  probably dont need functions for this//but I wanted to get used to calling them and passing things to them.int MultiplyNum(int first, int second){    int newnum;    newnum = first * second;    return newnum;}int DivideNum(int first, int second){    int newnum = first / second;    return newnum;}int AddNum(int first, int second){    int newnum = first + second;    return newnum;}int SubtNum(int first, int second){    int newnum = first - second;    return newnum;}///////////////////////////////////////int main(int argc, char *argv[]){    int finput, sinput, result;    int menuoption;    bool done = false;    while(!done){    system("cls");  //Start with a cls so the screen is fresh every time it returns to the menu.   cout << "===========================================" << endl;    cout << "=============Simple Calculator=============" << endl;    cout << "===========================================" << endl << endl;   cout << "   Menu Options" << endl;    cout << "--------------------" << endl;    cout << "1. Multiplication" << endl;    cout << "2. Division" << endl;    cout << "3. Addition" << endl;    cout << "4. Subtraction" << endl;    cout << "5. Quit" << endl <<endl;   cout << "Please Choose an option: ";    cin >> menuoption;    if(menuoption == 1)    {   system("cls");   cout << "Please enter the first number: ";   cin >> finput;   cout << "Please enter the second number: ";   cin >> sinput;   result = MultiplyNum(finput, sinput);   cout << "The answer is " << result << endl;   system("PAUSE");  //pause so you can actually have time to see the answer   }   else if (menuoption == 2)   {   system("cls");   cout << "Please enter the first number: ";   cin >> finput;   cout << "Please enter the second number: ";   cin >> sinput;   result = DivideNum(finput, sinput);   cout << "The answer is " << result << endl;   system("PAUSE");   }   if (menuoption == 3)   {   system("cls");   cout << "Please enter the first number: ";   cin >> finput;   cout << "Please enter the second number: ";   cin >> sinput;   result = AddNum(finput, sinput);   cout << "The answer is " << result << endl;   system("PAUSE");   }   else if(menuoption == 4)   {   system("cls");   cout << "Please enter the first number: ";   cin >> finput;   cout << "Please enter the second number: ";   cin >> sinput;   result = SubtNum(finput, sinput);   cout << "The answer is " << result << endl;   system("PAUSE");   } if (menuoption == 5)   {   system("cls");   cout << "Thanks for using this simple calculator!" << endl;   done = true;   }   else if(menuoption > 5 || menuoption < 1)   {  system("cls");  cout << "That is not a valid selection." << endl;  system("PAUSE");   }    }    system("PAUSE");    return EXIT_SUCCESS;}Am I using the if/else if statements right?Thanks in advance guys!EDIT:  figured out the source tag.   
  Nice program.You could impove it by changing this part:int MultiplyNum(int first, int second){    int newnum;    newnum = first * second;    return newnum;}int DivideNum(int first, int second){    int newnum = first / second;    return newnum;}int AddNum(int first, int second){    int newnum = first + second;    return newnum;}int SubtNum(int first, int second){    int newnum = first - second;    return newnum;}to:int MultiplyNum(int first, int second){    return first * second;}int DivideNum(int first, int second){    return first / second;}int AddNum(int first, int second){    return first + second;}int SubtNum(int first, int second){    return first - second;}Also , replace "using namespace std" , with:using std::cout;using std::cin;using std::endl;And you could also  replace "if" statements with switch().(note:im not expert ,im just giving you a few ideas to try :))   ;  Not quite, these are all exclusive options, so they need to be chained with "else if" everywhere.if ( menuoption == 1 ) {  // do something} else if (menuoption == 2 ) {  // do something} else if (menuoption == 3 ) {  // do something} else if (menuoption == 4 ) {  // do something} else if (menuoption == 5 ) {  // do something}It's also better to not nest the indentation for this, since it gets too deep.Then there's natural alternative:switch (menuoption) {  case 1 :{ // do something break;    }  case 2 :{ // do something break;    }  case 3 :{ // do something break;    }  case 4 :{ // do something break;    }  default :    { // everything else    }};  Awesome guys.  Thanks.I never thought about just making the function return the result of first * second etc. instead of typing in everything.The switch() seems like a much better way to do what I was wanting.   