0
how to print maximum value of an array.
pls helppppp
5 Réponses
+ 2
Use if statement and else if or else. If array exists, make a variable equal array at the beginning index when i = 0 the first element. then compare that with other numbers, if condition is not met For loop keeps incrementing and the first element is compared to other ones. if condition is met, first element equals the new element and again is compared to other elements , and then at the end if it is the highest you can cout it. I told u what u need to do, you need to be creative and code it.
+ 1
note this might be easier to do with vectors.
+ 1
Or in an array-case you might also want to try using a new variable (max) which equals the first element and then compare everything else to it and change it to whatever is bigger. This way you keep the original array as well.
0
ok