Announcement

Collapse
No announcement yet.

Summing Numbers

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Summing Numbers

    Can anyone tell me why this doesn't sum numbers or tell me of a better way to do it.
    x = x
    for T = 1 to 8
    x= x +5
    print x +5
    delay 1
    x = x
    next T

    it seems that the numbers should be 5,10,15,20,25,30,35,40.

    print "The total for the 5 numbers should be ";x (40).
    My problem is, when I get to the "x" above, the numbers are not added together.

    My goal is to write a routine to sum several numbers. And at the end,
    I've been struggling with this for 3 hours and could not get it to work.

    ------------------

  • #2
    Keith,

    What you are asking for and the information supplied in your "non-working"
    demo contradict each other.

    In english (not code or psuedo code) describe what your are
    trying to do and we'll work from there.

    ------------------
    Every day I try to learn one thing new,
    but new things to learn are increasing exponentially.
    At this rate I’m becoming an idiot faster and faster !!!
    ------------------
    George W. Bleck
    Lead Computer Systems Engineer
    KeySpan Corporation
    <b>George W. Bleck</b>
    <img src='http://www.blecktech.com/myemail.gif'>

    Comment


    • #3
      Keith, by now you may be smacking your head against a wall and going dooh!
      Nevertheless, your problem is that you are incrementing the value of x by 5 before printing it. Just "Print x" instead of "Print x+5"and it will be fine.

      ------------------
      [email protected]
      :) IRC :)

      Comment


      • #4
        Code:
        x = x
        While it's nice someone has finally posited[ yes, p-o-s-i-t-e-d] something on which we can all agree, this statement is totally superfluous and does nothing.

        MCM

        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          Eliminate Print x+5 just print x.
          Eliminate x=x as x will always equal x


          ------------------
          There is no gravity, the earth sucks.

          Comment

          Working...
          X