How do i write this??

Write a program consisting of a while loop, that reads the value of a double each time around. Create two variables that stores the values of the largest and smallest value it read so far.
First attempt this on your own. If you face any specific problem then ask. If you have already tried it, then show us your attempt.
Yeah i did already.

Okay, here is my specific problem.
i have created two variables, max and min. Each storing the maximum and minimum values respectively.

But the thing is i can only get around this my initializing both values to zero (0).

So after i input my first value, lets say 26,
max = 26 and min = 0

when i input a second value, lets say 32
max=32 and min still = 0

but i dont want that. I dont want the program to read zero. i wan it to read just inputted values.

That is, after inputting first value, lets say 26,
i want:

max=26 and min =26

and after inputting second value, lets say 32
max=32 and min=26
make the 1st read before the while loop:

1
2
3
4
5
6
std::cin >> var_double;
max = var_double;
min = var_double;
while (--number_of_values_to_read) {
  // further reads.
}
Try setting your min value to the highest value in the range
Topic archived. No new replies allowed.