# Computer Science

posted by .

After reviewing an algorithm that allowed a user to enter 3 different numerical values, if statements were used to find the smallest value.

Smallest of five: The assignment is to determine which method (either nested conditions, sequential compound conditions, nested and compound conditions, or using a placeholder variable) would be the best method for determining the smallest number of five user inputs which may contain duplicate values AND to write the algorithm for the problem.

We have not studied arrays or loops - only if statements so far. We are using Visual Logic or writing out if/else statements to arrive at the answer.

I wrote out how to find the smallest number of three numbers, but I don't know how to find the smallest number of five if there are two inputs that are the same number.

Should I use sequential or nested and compound conditions or a placeholder variable method?

Here's what I have so far:
Input num1
Input num2
Input num3
Input num4
Input num5
If num1 < num2 true then
if num1 < num3 true then
if num1 < num4 true then
if num1 < num5 true then
output &num1 "is the smallest."
Else if num1 = num2 true then
output &num "numbers are equal."
Else if num1 = num2 false then
if num1 > num3 true then...

ok...I'm stuck.

Anybody understand any of this? Can you help me with the thinking part of the logic on how to come up with how to solve this so I can get it on paper to think about before I get it into my head wrong?

Thanks,
Kimberly (42 year old student...now you understand...)

• Computer Science -

I'd use a placeholder value, and compare it against the other values as they come in:

input small

input num2
if num2 < small then small = num2
likewise for num3,4,5

output small "is the smallest"

If you aren't interested in reporting any duplicate values, then that's all there is to it. In fact, unless you want to report something about the incoming numbers, you can just use "num" for the input value each time.

## Similar Questions

1. ### mathematics

Let 5a + 12b and 12a + 5b be the side lengths of a right-angled triangle and 13a + kb be the hypotenuse, where a, b and k are positive integers. Find the smallest possible value of k and the smallest values of a and b for that k.
2. ### math

Let 5a + 12b and 12a + 5b be the side lengths of a right-angled triangle and 13a + kb be the hypotenuse, where a, b and k are positive integers. Find the smallest possible value of k and the smallest values of a and b for that k
3. ### math

Let 5a + 12b and 12a + 5b be the side lengths of a right-angled triangle and 13a + kb be the hypotenuse, where a, b and k are positive integers. Find the smallest possible value of k and the smallest values of a and b for that k
4. ### Mathematics

Let 5a+12b and 12a+5b be the side lengths of a right-angled triangle and 13a+kb be the hypotenuse, where a,b and k are positive integers. find the smallest possible value of k and the smallest values of a and b for that k.
5. ### C programming

A few questions, all involving "for" loops that I am unsure how to do (Thank you in advance for the help): Q1.) Write a table of conversions from Celsius to Rankin. Allow the user to enter the starting temperature and increment between …
6. ### Computer Programing & Logic Design

Submit pseudocode and a flowchart for the following programming exercise: Largest and Smallest Design a program with a loop that lets the user enter a series of numbers. Theuser should enter -99 to signal the end of the series. After …
7. ### Computer Programing & Logic Design

Submit pseudocode and a flowchart for the following programming exercise: Largest and Smallest Design a program with a loop that lets the user enter a series of numbers. Theuser should enter -99 to signal the end of the series. After …
8. ### Mathematics

let 5a+12b and 12a+5b be the sides length of a right-angled triangle and let 13a+kb be the hypotenuse,l where a,b and k are positive integers. find the smallest possible value of k and the smallest values of a and b for that k.
9. ### computer

Write an algorithm for a program that accepts a set of numbers and finds the smallest among them and computes the sum of the numbers accepted. The program stops when the user enters number 999. Convert the algorithm into flowchart
10. ### Computer science

What is the smallest value of n such that an algorithm whose running time is (2^15)n runs faster than an algorithm whose running time is 2^n on the same machine?

More Similar Questions