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
olga2289 [7]
3 years ago
14

[Random Number Generator] Write a program that generates 10 random integers between the boundary from the user input. Display al

l the random numbers, the greatest value, the smallest value and the average of the random numbers. Requirement: Input Validation: Do not accept the lower bound value is greater or equal to the higher bound. Or simply switch the low and high values. Write functions to generate the random numbers and store in an array, find the greatest value, the smallest value and average from the array. Display the programmer info at the beginning of the output Include the function prototypes before the main() All functions definitions should be after the main() Required function headers: void showValues(const int a[], int size); // display the content of the array void fillArray(int a[], int size, int low, int higt); // fill up array elements between low and high int maximum(const int a[], int size); // return the highest value from the passing array int minimum(const int a[], int size); // return the lowest value from the passing array double average(const int a[], int size); // return the average of the passing array
Computers and Technology
1 answer:
wel3 years ago
6 0

Answer:

#include<iostream>

#include<cstdlib>

#include<ctime>

using namespace std;

void showValues(const int a[], int size);

void fillArray(int a[], int size, int low, int high);

int maximum(const int a[], int size);

int minimum(const int a[], int size);

double average(const int a[], int size);

int main(){

int size = 10;

int low,high;

cout<<"Low: ";

cin>>low;

cout<<"High: ";

cin>>high;

if(high<low){

high = high + low;

low = high - low;

high = high - low;

}

int a[size];

//Enter your details here e.g. cout<<"Name: Programmer XYZ"

fillArray(a, size, low, high);

showValues(a, size);

cout<<"Maximum: "<<maximum(a, size)<<endl;

cout<<"Minimum: "<<minimum(a, size)<<endl;

cout<<"Average: "<<average(a, size)<<endl;

}

void fillArray(int a[], int size, int low, int high){

unsigned seed = time(0);

  srand(seed);

for (int j = 0;j<size;j++){

 a[j]=low + rand() % (( high+ 1 ) - low);  

}

}

void showValues(const int a[], int size){

for(int i =0;i<size;i++){

cout<<a[i]<<" ";

}

cout<<endl;  

}

int maximum(const int a[], int size){

int max = a[0];

for(int i =1;i<size;i++){  

if(a[i]>max){

 max = a[i];

}

}  

return max;

}

int minimum(const int a[], int size){

int min = a[0];

for(int i =1;i<size;i++){  

if(a[i]<min){

 min = a[i];

}

}  

return min;

}

double average(const int a[], int size){

double total = a[0];

for(int i =1;i<size;i++){  

total+=a[i];

}

return total/size;

}

Explanation:

<em>This solution is implemented in C++. The source code is a bit length. So, I added the explanation as an attachment of the source file where I used comments to explain some lines.</em>

Download cpp
You might be interested in
32.
qaws [65]

Answer:

a

Explanation:

hackers access your system unauthorized

5 0
3 years ago
1. Which of the following are examples of applied art? Select all that apply. (2 points)
Svetlanka [38]

Answers

1. Examples of applied in the list art are Architecture, Drawing and industrial design.

2. The following can be considered an artist’s media; substrate onto which art is created (ex: canvas, paper) and material with which to create art (ex: paint, clay)

Explanations

Applied art is the application of both artistic and design principles to practice and practical use. This type of art can be fine art and theoretical in practice. Examples of applied art are drawing and painting illustrations, woodblock prints, Print based art, industrial and interior design, architecture, car and toy design, landscaping, tattoos and pottery. An art media is the material used by an artist or designer to create a piece of work.





6 0
3 years ago
Read 2 more answers
How do you feel about the Furry Fandom?
gtnhenbr [62]
When you don’t know who or what that is, and I pop- lol I need a life
8 0
3 years ago
Where can the slide layout be changed
NeTakaya
To change<span> an existing </span>layout<span>, do one or more of the following: To add a placeholder, on the </span>Slide<span> Master tab, click Insert Placeholder, and then select a placeholder type from the list. Click a location on the </span>layout<span>, and then drag to draw the placeholder. Resize, reposition, or delete a placeholder.</span>
4 1
3 years ago
Read 2 more answers
Which of the following agencies protects human health and the natural environment?
Alex Ar [27]
The answer to this is the EPA 
 

7 0
3 years ago
Read 2 more answers
Other questions:
  • The rubric given to them by their teacher requires that
    14·1 answer
  • What are the ethical implications of online social media after someone has died?
    13·1 answer
  • Create a style rule for the page body that sets the width to 95% of the browser window ranging from 640 pixels up to 960 pixels.
    11·1 answer
  • Two boxes overlap if their interiors have at least one point in common. Give an O(n log n)-time algorithm that decides if there
    8·1 answer
  • Which of the following is a subsystem of computers providing access to the Internet and offering multimedia and linking capabili
    13·1 answer
  • Which is used to identify the network portion and the host portion of an ip address?
    6·1 answer
  • Assume there is a class AirConditioner that supports the following behaviors: turning the air conditioner on and off. The follow
    7·1 answer
  • How do you get past a firewall ?
    15·1 answer
  • Yo, my Lenovo laptop keeps showing this screen but I can't sign in, can someone help me?
    5·2 answers
  • Difference between sorting and filtering​
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!