Академический Документы
Профессиональный Документы
Культура Документы
1. Display to the user: “INPUT 5 NUMBERS”, and the user must input 5
numbers.
2. Set the tempVar variable (int data type) equal to the first integer inputted
by the user.
4. Repeat the previous step and stop when there are no integers left in the
sequence. The tempVar variable at this point is the largest integer in the set.
Sample Output:
2. An algorithm that reverse the sequence (From lowest to highest)
1. Display to the user: “INPUT 5 NUMBERS”, and the user must input 5 numbers.
2. Set the tempVar variable (int data type) equal to the first integer inputted by the user.
4. Compare the next integer in the sequence to the tempVar, and if it is larger than the
tempVar variable: set the tempVar's value equal to the larger integer and display it to the
user afterwards.
5. Repeat the previous step and stop when there are no numbers left to compare to.
6. At this point, the result will be displayed to the user in ascending order.
Sample Output:
2. Set the tempVar variable (int data type) equal to the first integer inputted by the user.
4. Compare the next integer in the sequence to the tempVar, and if it is smaller than the
tempVar variable: set the tempVar's value equal to the smaller integer and display it to
the user afterwards.
5. Repeat the previous step and stop when there are no numbers left to compare to.
6. At this point, the result will be displayed to the user in descending order.
Sample Output
3. Compute the Greatest Common Divisor (Using Euclidean Algorithm).
1. Display “INPUT TWO NUMBERS:”, and the user must then input two
numbers (The 1st number must be larger than the 2nd number).
2. Divide the two numbers and get the result, and the remainder. (A ÷ B = C
with remainder R).
Computation: