Welcome to Westonci.ca, your one-stop destination for finding answers to all your questions. Join our expert community now! Connect with professionals on our platform to receive accurate answers to your questions quickly and efficiently. Experience the ease of finding precise answers to your questions from a knowledgeable community of experts.
Sagot :
Answer:
In C++
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector<int> Vector1, Vector2, Vector3; int total2 = 0, total3 = 0, count2 = 0, count3 =0;
srand((unsigned)time(NULL));
int total = 0;
for (int kt =0; kt < 100; kt++){
int b = rand() % 50 + 1;
Vector1.push_back(b);
cout << Vector1[kt] << " ";
total+=b; }
double avg = (total * 1.0)/100.0;
cout<<endl<<"Overall Average: "<<avg<<endl;
for (int kt =0; kt < 100; kt++){
if(Vector1[kt]>=1 && Vector1[kt]<=30){
Vector2.push_back(Vector1[kt]); total2+=Vector1[kt]; count2++; }
else{
Vector2.push_back(Vector1[kt]); total3+=Vector1[kt]; count3++; } }
double avg1 = (total2 * 1.0)/count2, avg2 = (total3 * 1.0)/count3;
cout<<"Average 1 - 30: "<<avg1<<endl;
cout<<"Average 31 - 50: "<<avg2<<endl;
double avg3 = (avg1 + avg2)/2;
cout<<"Average of Average: "<<avg3<<endl;
if(avg == avg3){ cout<<"Both average are equal"; }
else{ cout<<"Both average are not equal"; }
return 0;}
Explanation:
See attachment for complete question where comments were used to explain each line
Thank you for visiting. Our goal is to provide the most accurate answers for all your informational needs. Come back soon. Thank you for choosing our platform. We're dedicated to providing the best answers for all your questions. Visit us again. We're here to help at Westonci.ca. Keep visiting for the best answers to your questions.