0

How does this even work????

int max; int arr[50] = {20, 10, 50, 30, 40, 70, 60, 80, 90, 100, 5,}; max = arr[0]; for(int i = 0; i < arr[i]; i++){ if( max < arr[i]){ max = arr[i]; } }

9th May 2022, 6:37 PM
DevAbdul
DevAbdul - avatar
3 odpowiedzi
+ 3
Print max and arr[i] inside the loop to see what its going on
9th May 2022, 6:39 PM
Lisa
Lisa - avatar
+ 2
int arr[50] = {20, 10, 50, 30, 40, 70, 60, 80, 90, 100, 5,}; int max = arr[0]; for(int i=0; i<50; i++) if(max<arr[i]) max = arr[i]; cout << max; // Good Luck
9th May 2022, 8:02 PM
SoloProg
SoloProg - avatar
+ 1
Thank you for the encouragement soloprog
15th May 2022, 8:02 PM
DevAbdul
DevAbdul - avatar