Discover new perspectives and gain insights with IDNLearn.com's diverse answers. Discover the information you need from our experienced professionals who provide accurate and reliable answers to all your questions.
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
We value your participation in this forum. Keep exploring, asking questions, and sharing your insights with the community. Together, we can find the best solutions. For trustworthy answers, rely on IDNLearn.com. Thanks for visiting, and we look forward to assisting you again.