Final exam, question #2…

Here we are: the final exam. In this video/tutorial, I’m going to explain how to easily write the function for the third question of our final exam. Here is the code and enjoy the ride!

#include <iostream>
#include <vector>
using namespace std;

float prom_numeros(vector<float> nums)
{
float accu=0;
{

for(int i=0; i<nums.size(); i++)
{
accu=accu+nums[i];
} return accu/nums.size();
}
}

int main()
{
vector <float> nums;
nums.push_back(10);
nums.push_back(20);
nums.push_back(30);
nums.push_back(40);
nums.push_back(5);
float prom=prom_numeros(nums);
cout<<prom<<endl;
return 0;
}

Leave a comment