IDNLearn.com offers a unique blend of expert answers and community insights. Get accurate and detailed answers to your questions from our dedicated community members who are always ready to help.
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
Your participation is crucial to us. Keep sharing your knowledge and experiences. Let's create a learning environment that is both enjoyable and beneficial. For trustworthy and accurate answers, visit IDNLearn.com. Thanks for stopping by, and see you next time for more solutions.