Arithmetic Help

This is a discussion on Arithmetic Help within the C++ Programming forums, part of the General Programming Boards category; Hey, how do I assign a math problem to a variable? Example: x + y > answer (variable) I want ...

  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    5

    Question Arithmetic Help

    Hey, how do I assign a math problem to a variable? Example:

    x + y > answer (variable)

    I want to do something of that formula, instead of:

    cout << "x + y";

  2. #2
    Registered User BuzzBuzz's Avatar
    Join Date
    Feb 2009
    Posts
    89
    To assign something the equation goes to the right:

    variable = x + y

    However, you've got two completely different things going on in your question:

    x + y > answer (variable)
    would mean that x + y is greater than answer

    cout << "x + y";
    would give you the output:

    Code:
    x + y

  3. #3
    Registered User
    Join Date
    Jul 2004
    Posts
    222
    I don't know what you mean by assigning a math problem to a variable. You can assign an expression to a variable, for example:

    answer = x + y;

    If you want to display the expression "x + y", you assign "x + y" to a string variable. I'm not sure if I've missed your question.

  4. #4
    Registered User
    Join Date
    Mar 2009
    Posts
    5
    Quote Originally Posted by BuzzBuzz View Post
    To assign something the equation goes to the right:

    variable = x + y

    However, you've got two completely different things going on in your question:



    would mean that x + y is greater than answer



    would give you the output:

    Code:
    x + y
    Thanks, I got it now. I used > more as an arrow to go into the variable, but I understood how it could be mixed up. Thanks again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. GNU Multiple Precision Arithmetic Library Problem
    By parad0x13 in forum C++ Programming
    Replies: 1
    Last Post: 07-19-2008, 05:16 PM
  2. bitwise and arithmetic Operators
    By Whiteghost in forum C Programming
    Replies: 4
    Last Post: 12-28-2006, 02:13 PM
  3. arithmetic operator friend functions
    By linucksrox in forum C++ Programming
    Replies: 7
    Last Post: 02-06-2006, 11:39 PM
  4. Replies: 3
    Last Post: 05-01-2003, 01:47 PM
  5. Replies: 1
    Last Post: 11-19-2001, 04:45 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21