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
Explain at least one reason why programming languages have functions
Salsk061 [2.6K]
With functions we can separate different parts of our code. each functions implements a single logical part of the program.

for example sqrt() function does square root. so we can use it in different programs, because it's a stand-alone component.

6 0
3 years ago
In the Word 2016 window, where is the Status bar located?
klasskru [66]

Answer:

I hope this helps

Explanation:

The answer is B

4 0
3 years ago
Which is the purpose of adding B-Roll footage to a sequence?
pav-90 [236]

Answer:

To add richness in content – B-roll footage is used to increase the depth of the main footage and improve storytelling.

Explanation:

Hope this helps

7 0
4 years ago
Draw the gates required to build a half adder.
Svetach [21]

Answer:

The gates required to build a half adder are :

  1. AND Gate for Carry.
  2. XOR Gate for Sum

Explanation:

AND Gate is required for the carry and the XOR gate is required for the sum.

The figures for the gates and the truth tables for the half adder are attached so please refer them for further explanation.

The sum is 1 when one of the input is High or 1 if both the inputs are same then the sum is 0.So this behavior is implemented by X-OR gate.

The carry is High only when both of the inputs are 1.This is implemented by AND-Gate.

6 0
3 years ago
What is a many-to many types of correspondence?
Ann [662]

Answer:

We have many types of correspondences. There are internal correspondences, external correspondences, sales correspondences, and personalized correspondences. By many to many correspondences we mean, a lot of people correspond with a lot many people from another department, company or market, or any set of people in fact. An internal correspondences, sales correspondences, personalized correspondences or external correspondences can be of many to many types, and as well as of others like one to one, many to one and so on.

Explanation:

Please check the answer.

5 0
3 years ago
Other questions:
  • Suppose you have a certain amount of money in a savings account that earns compound monthly interest, and you want to calculate
    10·2 answers
  • Kwan is using JavaScript extensively to add interactivity to his Web site. Contained within his script is a counter object that
    8·1 answer
  • ATM machines respond to request in__________​
    13·1 answer
  • Which expression correctly determines that String s1 comes before String s2 in lexicographical order
    6·1 answer
  • What considerations should you make when deciding on the size of a table?
    9·1 answer
  • If you are going to refer to a few dozen classes in your application, how do<br> you do it?
    6·1 answer
  • if ur parent gets mad at u and says something then u say something, why do they say "stop back talking'' if ur just starting a c
    7·2 answers
  • Every Java statement ends with: *<br><br> Period<br> Colon<br> Double quote<br> Semicolon
    11·2 answers
  • The term platform as a service has generally meant a package of security services offered by a service provider that offloads mu
    9·1 answer
  • Why would a business consider using virtual machines?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!