cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Checking Values In For Loop
Checking Values In For Loop
Oct 17, 2015 at 6:03pm UTC
joshuatz
(25)
How would I check for the highest value inside a for loop?
Like if my for loop prints out
3575
3622
3660
3705
3712
3710
3697
3675
how could I set the highest value equal to 3712 just using loops and if statements?
Oct 17, 2015 at 6:17pm UTC
LB
(13399)
Assume the first element is the highest element. As you loop through the values, check if the current value is higher than the highest value. If so, update the highest value. After the loop, you're guaranteed to have the highest value.
Oct 17, 2015 at 6:56pm UTC
joshuatz
(25)
How could I save the number from the first iteration over to the second iteration? When I try to do it, it just gives me the last number of iteration.
Oct 17, 2015 at 6:57pm UTC
LB
(13399)
Create a variable before the loop?
Oct 17, 2015 at 7:09pm UTC
joshuatz
(25)
Thank you so much.
You're a boss.
I forgot to do that.
Topic archived. No new replies allowed.