1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Andreyy89
3 years ago
5

Using vectors: Create a vector of integers of size 100, with random numbers ranging from 1 to 50. Print out these 100 numbers in

a readable format. Find the average of these 100 numbers, print out the overall average. Then take the original list of 100 numbers, and find all the numbers that are between 1 and 30 and put them into a new vector. Do the same with all the numbers from 31 to 50 putting them into a third vector. Find the average of vectors 2 and 3 and call them avg1 and avg2. Print out avg1 and avg2. Find the average of avg1 and avg2. Write a final output line showing/comparing the average from step 3 and the average from step 7 are not the same, and hence the average of averages doesn't work. You have just proved a mathematical theorem.
Computers and Technology
1 answer:
zysi [14]3 years ago
8 0

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

Download cpp
You might be interested in
Tim is trying to explain to his aunt how her computer works, but she does not understand what a CPU does. Which description will
Art [367]
The CPU processes commands from software
6 0
4 years ago
Read 2 more answers
Match the definitions to their respective cli hot keys and shortcuts. (not all options are used.)
lord [1]
  • Tab ( Complete omitted commands and parameters )
  • Space bar ( Display the next screen )
  • Up arrow ( Scroll backward through previously entered commands )
  • ? ( Provides context-sensitive help )
  • Ctrl Shift 6 ( Cancel commands such as trace and ping).

What is CLI tools ?

A command line interface (CLI) is a text-based user interface (UI) used to run programs, manage computer files, and interact with a computer. A command line interface is also known as a command line user interface, console user interface, or character user interface.

Why do we use CLI tools ?

The CLI is a command line utility that accepts text input and executes operating system functions. In the 1960s,  this was the only way to interact with a computer, as only computer terminals were in use. In the 1970s and 1980s, command line input was widely used on Unix systems and personal computer systems such as MS-DOS and Apple DOS.

To know more about CLI Tools visit here:

brainly.com/question/13263568

#SPJ4

4 0
1 year ago
Which Tab contains the paragraph attributes?
alexgriva [62]

Answer:

b insert

Explanation:

7 0
3 years ago
What are the responsibilities of the DBA and the database designers?
Ratling [72]

Answer:

Explanation:

DBA's main responsibility is making sure that there is enough CPU, disk, memory, and network bandwidth available, as well as making backups every so often. Meanwhile, the database designers/developers are responsible for investigating and implementing what the end-user needs and making sure that the database holds all of the information that the end-user will be using.

3 0
3 years ago
State whether True / False:<br>The pause option stops the recording temporarily.*<br>True<br>False​
defon

Answer:

true

Explanation:

when you pause a recording it will temporarily stop but, when you hit record again it will continue where you left off

7 0
3 years ago
Other questions:
  • To change the caption for a field in a query, click the field in the design grid, click the ____ button on the Design tab, click
    14·1 answer
  • Select the correct answer.
    9·2 answers
  • Alto Innovations creates custom software for organizations. The company's managers want to build a high-performance culture in t
    11·1 answer
  • Plz help me of this answer<br><br><br>language:python​
    7·2 answers
  • The _______ is the continuing development of the internet that allows everyday objects embedded with electronic devices to send
    11·1 answer
  • One way that Intuit handles the ________ of its TurboTax and other financial software is through its websites. The site includes
    11·2 answers
  • The length of the hypotenuse of a right-angled triangle is the square root of the sum of the squares of the other two sides. Wri
    7·1 answer
  • When a laptop internal device fails, what three options can you use to deal with the problem?
    7·1 answer
  • 3. Maria is in charge of consolidating the names of the participants of the two-day virtual
    13·1 answer
  • The aim of this activity is to implement an algorithm that returns the union of elements in a collection. Although working with
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!