I have to do three small programs that use loops. I know how to do the loops but am unsure about how to do the rest for exercises 1 and 2. I think that I can do exercise 3 fully on my own.
For the first part, I have to calculate the sum of the integer entered.
If the user typed in 698, how would I commute the sum? Would I declare sum= integer? (interger being the number entered).
Sample:
Please input an integer between 0 and 1000: 1001
* Number not in 0-1000 range. Please re-enter: -1
* Number not in 0-1000 range. Please re-enter: 456
Sum of the digits is 15
For the second one, the user has to enter 3 intergers and they have to be sorted from smallest to largest. I don't know how to get them sorted from smallest to largest.
Sample run:
Input integer 1 : 34
Input integer 2 : 200
Input integer 3 : -14
Sorted : -14 <= 34 <= 200



LinkBack URL
About LinkBacks


