I would like to know how to determine the highest number and the lowest number out of whatever numbers the user inputs. We’re supposed to display those after the user enters 99. Everything I found is using arrays, and we’ve not yet learned those. Please help!
string input;
int input2;
Console.WriteLine("Enter an integer");
input = Console.ReadLine();
input2 = Convert.ToInt32(input);
while (input2 != 99)
{
Console.WriteLine("Enter an integer");
input = Console.ReadLine();
input2 = Convert.ToInt32(input);
}
The idea of imperative programming is to give a sequence of statements (an algorithm) that mutate state (a set of variables) until it contains the desired result.
For example, your program changes the contents of the variables
inputandinput2untilinput2contains the value99.To find the highest and lowest integer, define two variables,
highestandlowest. Change their contents in thewhileloop such that, after each iteration, they contain the highest and lowest integer respectively, taking the current input value into account.