Question: why is my code doing this? My code: #include #include #include using namespace std; int main() { vector weights; double weight = 0.0; double sum
why is my code doing this?
My code:
#include
using namespace std;
int main() { vector weights;
double weight = 0.0; double sum = 0.0; double average = 0.0; double maxWeight = -1.0;
for (int i = 1; i > weight; weights.push_back(weight); }
cout maxWeight) { maxWeight = weights[i]; } cout
average = sum / 5.0;
cout
return 0; }
Output differs. See highlights below. Input 236.0 89.5 142.0 166.3 93.0 Your output starts with Enter weight 1: Enter weight 2: Enter weight 3: Enter weight 4: Enter weight 5: You entered: 236.00 89.50 142.00 166.30 93.00 0.00 Expected output starts with Enter weight 1: Enter weight 2: Enter weight 3: Enter weight 4: Enter weight 5: You entered: 236.00 89.50 142.00 166.30 93.00
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
