Jump to content
  • Advertisement

Scot Garcia

Member
  • Content Count

    9
  • Joined

  • Last visited

Community Reputation

114 Neutral

About Scot Garcia

  • Rank
    Newbie
  1. Scot Garcia

    Very simple calculator

    Okay, so, should I be asking why it says void in front?  Or will that just confuse me?   And if I understand you correctly:   OutputEquation(int a, char op, int b, int c)   When OutputEquation is called upon, if the all arguments aren't defined, then it'll bug out?  i.e.  I provide, int a, char op, and int b, but not int c.       AND lastly, does a variable have to be initialized for every function?
  2. Scot Garcia

    Very simple calculator

    Okay, so, I'm not exactly sure what a constant is (I'm only just breaking into loops in my self taught classes), but I'll take a gander that they're variables that're defined before the main () function?   I understand most of the code you wrote 0r0d, for the most part, but the following function I haven't learned yet, and it confuses me for sure:   void OutputEquation(int a, char op, int b, int c) { cout << a << " " << op << " " << b << " = " << c << endl; }
  3. Scot Garcia

    Very simple calculator

      I think I'm going to have to keep this little guide handy!
  4. Scot Garcia

    Very simple calculator

      Thank you 0r0d.  I think understanding how to debug your own code is one of the most important parts of programming, and I'd definitely like to understand how the computer see's these errors.
  5. Scot Garcia

    Very simple calculator

      Haha, thank you!   Did you noticed that right away Paradigm, or did the error give you an idea as to what to look for?  Because whenever I look at the compiler error, all I ever manage to understand in it is "error: this crap is broke!"
  6. Scot Garcia

    Very simple calculator

    Okay, so, I got rid of trying to define c and implemented a 4 part else if statement (I haven't learned about switch yet), and now I'm getting one last error:   #include <iostream> #include <string> using namespace std; int main () { string symbol; int a; int b; cout << "Please decide what kind of operation you'd like to complete: "; cin >> symbol; cout << "And now please decide the first number for the operation: "; cin >> a; cout << "And now the second, please: "; cin >> b; if ( symbol == "+" ) { cout << a << " + " << b << " = " << a + b << endl; } else if ( symbol == "-" ) { cout << a << " - " << b << " = " << a - b << endl; } else if ( symbol == "*" ) { cout << a << " * " << b << " = " << a * b << endl; } else { cout << a << " / " << b << " = " a / b << endl; // error: expected ';' before 'a' return 0; } }  
  7. Scot Garcia

    Very simple calculator

    Okay, the objective of this is to have the user pick one of the four basic arithmetic operations (addition, subtraction, multiplication and division), and then pick the 2 integers for the operation, and then have the program spit out the result.  I seem to be having a problem storing the symbol for the math operation and then using it at the end to actually perform the math.  Here's what I got so far:   #include <iostream> using namespace std; int main () { char symbol; int a; int b; cout << "Please decide what kind of operation you want done; +, -, * or /: "; cin >> symbol; cout << "Now please enter the first number: "; cin >> a; cout << "And the second: "; cin >> b; int c = a, symbol, c; cout << c; } I think my problem is how the symbol is stored, and char isn't cutting it.   So, any advice would be great!
  8. Scot Garcia

    getline/else if

    Thank you so much guys!  I wasn't aware getline was part of <string> and I got so used to a semi-colon going at the end of everything, that I must've blocked out the part where it says NOT to put them in the if/else statements.
  9. Scot Garcia

    getline/else if

    Just starting out in this programming adventure, and I've run into a problem already with my getline function and else if.   Here is my code:   #include <iostream> using namespace std; int main () { int billy; int jill; cout << "How old is Billy? " << "\n"; getline( cin, billy, '\n'); cout << "Okay! Now, how old is Jill? " << "\n"; getline ( cin, jill); if ( ( billy > 100 ) && ( jill > 100 ) ); { cout << "Wow! Those guys are ******* old!"; } else if ( billy > jill ); { cout << "Okay, so Billy is older than Jill. Expected."; } else ( billy < jill ); { cout << "Wait, so Jill was older than Bill? Interesting."; } }   Now it my compiler (I'm using code::blocks) says that there's no matching function for all to getline.  It works just fine if I switch it to:   cin >> billy So, I'm not sure what's wrong with the code.  I've reread the instruction book I have explaining getline, but it doesn't exactly explain the full use of it.   And secondly, when I switch the getline to cin >>, when my compiler get's to the else if statement, it says: error: 'else' without a previous 'if'   So, thanks ahead of time for any help, I'd definitely like to get past this point, and I don't want to move on before fully understanding what I've learned.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!