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
GalinKa [24]
3 years ago
7

Write a code in C++ that can save 100 random numbers in an array that are between 500 and 1000. You have to find the average of

the 100 random numbers. To find the average of the numbers, you have to use a functions. You are not allowed to use return, cin or cout statements in the functions.
Hint : you have to use function call by reference.
Computers and Technology
1 answer:
Anni [7]3 years ago
3 0

Answer:

#include <iostream>

#include <random>

//here we are passing our array and a int by ref

//to our function called calculateAverage

//void is infront because we are not returning anything back

void calculateAverage(int (&ar)[100], int &average){

 int sum = 0;

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

   //adding sum

   sum += ar[i];

 }

 //std:: cout << "\naverage \t\t" << average;

//calculating average here

 average += sum/100;

}

int main() {

 int value = 0;

 int average = 0;//need this to calculate the average

 int ar[100];

 //assign random numbers from 500 to 1000

 //to our array thats called ar

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

   value = rand() % 500 + 500;

   ar[i] = value;

   

 }

 calculateAverage(ar,average);

 // std:: cout << "\naverage should be \t" << average;

 

}

Explanation:

not sure how else this would work without having to pass another variable into the function but I hope this helps!

I commented out the couts because you cant use them according to ur prof but I encourage you to cout to make sure it does indeed calculate the average!

You might be interested in
what is the name of the fields in an x.509 digital certificate that are used when the parties negotiate a secure connection?
Zigmanuir [339]

Answer:

Image result for what is the name of the fields in an x.509 digital certificate that are used when the parties negotiate a secure connection?

Common applications of X. 509 certificates include SSL/TLS and HTTPS for authenticated and encrypted web browsing, signed and encrypted email via the S/MIME protocol, code signing, document signing, client authentication, and government-issued electronic ID.

Explanation:

8 0
3 years ago
What is unique about the TODAY and NOW functions?
Degger [83]

Answer:

The formula does not require arguments.

Explanation:

One of the programs or software that runs on a computer is Microsoft Office programs. One of these programs is called Microsoft Excel. It is a spreadsheet program where calculations can be made, graphs, diagrams can be plotted and drawn as well.

In other to utilize Microsoft Excel properly, we make use of what we call FUNCTIONS. Functions in Microsoft Excel are defined as formulas, that have already been prepared or created before hand in the Microsoft Excel program so that we can be able to used Microsoft Excel properly and efficiently. Functions may or may not require ARGUMENTS to carry out necessary calculations.

An ARGUMENT is a number or variable that functions require to carry out or do their calculations.

Examples of the functions found in Microsoft Excel are the TODAY and NOW functions. These two functions are used in spreadsheets on Microsoft Excel with regards to Date and Time.

TODAY function is used to give us or update the current or present date while the NOW function gives us or updated the current date and time.

The uniqueness or similarities between the TODAY and NOW functions is that their formula do not require arguments.

3 0
2 years ago
Read 2 more answers
Sales management wants a small subset of users with different profiles and roles to be able to view all data for compliance purp
Lapatulllka [165]

Answer:

Last Option is correct answer. ( Option D)

Explanation:

Option A is rejected because this will allow the view permission but as mentioned the management want a new profile for the users as well.

Option B is rejected because again it will not facilitate the different profile requirement.

Option C is not answer because It will only help in viewing the data and granting permission.

Option D is selected because it will meet both requirements which are to make a new profile first of all and then grant the View permissions to these profiles for the user subset.

7 0
3 years ago
Keith has to carry out a photo shoot to capture images of the ocean during the monsoons. What is a recommended practice when sho
Semmy [17]

Answer:

Answer is A: place absorbent chemical packets in the camera cover

Explanation:

Keith is required to carry adequate gear while going for a shoot. And in this case, he should carry anything that will protect his camera from the ocean and rainwater. By anything, I mean anything that Keith will use to stay dry. Using an air conditioner would be the worst idea. An air conditioner might blow the air towards your camera. Placing the camera in its case will ensure that it is dry and Keith will keep on shooting. Placing absorbent chemical packets in the camera cover will ensure that any water droplets that might fall on the cover of the camera will be absorbed. The point here is to keep dry.

6 0
3 years ago
Which step is first in changing the proofing language of an entire document?
Genrish500 [490]
Select the whole document by pressing Ctrl+a.
7 0
3 years ago
Other questions:
  • 1. You have recently been hired by a leading firm, which provides information management solutions to large corporations. As a n
    12·2 answers
  • Mathematical expression that might link numbers in cells
    14·1 answer
  • 14. Convert 11110111 from binary to denary<br> (1 Point)
    12·2 answers
  • Write a program that prints the following text: In C, lowercase letters are significant. main() is where program execution begin
    14·1 answer
  • Write a new program indent.cpp that enhances the program from the previous task. As it reads the input line by line, it should a
    10·1 answer
  • Write an expression that computes the integer average of the int variables exam1 and exam2 (both declared and assigned values).
    15·1 answer
  • Write a method named removeDuplicates that accepts a string parameter and returns a new string with all consecutive occurrences
    7·1 answer
  • Assume that x and y are boolean variables and have been properly initialized. !(x || y) || (x || y) The result of evaluating the
    10·1 answer
  • Will, there be any presents this year
    15·1 answer
  • 5. Write the name of the tab, command group, and icon you need to use to access the
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!