the use of loops

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • elsy
    New Member
    • Oct 2007
    • 1

    the use of loops

    you are to enter a number integer inside a loop. the loop terminates when you
    enter a value of -1 inside a loop. the integers are added as they are entered and their sum is displayed after the loop exits.
  • sicarie
    Recognized Expert Specialist
    • Nov 2006
    • 4677

    #2
    Sounds like a good assignment. After reviewing our homework policy, did you have a question on your assignment?

    Comment

    • jwwicks
      New Member
      • Oct 2007
      • 19

      #3
      Hello,

      Originally posted by elsy
      you are to enter a number integer inside a loop. the loop terminates when you
      enter a value of -1 inside a loop. the integers are added as they are entered and their sum is displayed after the loop exits.
      Basically just use a do while loop

      [code="cpp"]

      do{
      SomeValue = GetSomeValue();
      // Do some totalling stuff here...
      // If somevalue != -1
      }while( SomeValue != ExitCode);

      [/code]

      John

      Comment

      Working...