309,922 views
37 votes
37 votes
Find the maximum value and minimum value in milestracker. Assign the maximum value to maxmiles, and the minimum value to minmiles.

User Suroh
by
2.7k points

1 Answer

15 votes
15 votes

Python:

#TODO: Update the milestracker as you wish.

milestracker = [3,4,5,6,7,8,9,10,11]

#Find max and min and then print those values.

maxmiles = max(milestracker)

minmiles = min(milestracker)

print("The maximum:",maxmiles,"\\The minimum:",minmiles)

C++:

#include <bits/stdc++.h>

int main(int argc, char* argv[]) {

//TODO: Update the milestracker as you wish.

std::vector<int> milestracker{2,3,4,5,6,7,8,91,10,11};

//Compare and then print.

int maxmiles = *std::max_element(milestracker.begin(),milestracker.end());

int minmiles = *std::min_element(milestracker.begin(),milestracker.end());

std::cout << "The maximum: " << maxmiles << "\\The minimum: " << minmiles << std::endl;

return 0;

}