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]
2 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]2 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
Assume you're using a three button mouse. To connect shortcut menus, you would what
Grace [21]
You would click the right button to a shortcuts

5 0
2 years ago
A foreign exchange student brought his desktop computer from his home in Europe to the United States. He brought a power adapter
lidiya [134]
The European plug takes up 220 volts while the American one takes 110 volts.
6 0
2 years ago
Where do you place the title tag in HTML​
makkiz [27]

Answer:

The title tag is basically your saved document

Save as and poof

High Hopes^^

Barry-

5 0
2 years ago
What is the common name for the growth rate function N?
kolezko [41]

Answer:

Linear.

Explanation:

The common name for the growth rate function N is linear.N growth rate is directly proportional to the input.So it grows linearly.It does not grow rapidly like other growth functions like quadratic,exponential and cubical.

Constant growth does not grow over time it stays as it is.

Hence the answer to this question is linear.

3 0
2 years ago
true or false if you type too much text on a powerpoint slide, the additional text is added to a second slide
Nady [450]
True I've had it happen alot
3 0
3 years ago
Read 2 more answers
Other questions:
  • What websites can help you learn about general career treads
    11·1 answer
  • The analog signals that carry analog or digital data comprise composites built from combinations of simple sine waves.
    12·1 answer
  • Over time, programming languages have evolved in phases called ________.
    5·2 answers
  • Write a class called (d) Teacher that has just a main method. The main method should construct a GradeBook for a class with two
    7·1 answer
  • In 1-2 sentences, describe some keyboard shortcuts you have used during this lesson to save you time.
    13·2 answers
  • A junior administrator is having issues connecting to a router's console port using a TIA/EIA 568B standard cable and a USB seri
    5·1 answer
  • What enables image processing, speech recognition, and complex game play in Artificial Intelligence (AI)?
    7·1 answer
  • How are keyboards applied in the real world
    13·1 answer
  • Assume the user responds with a 3 for the first number and a 5 for the second number.
    13·1 answer
  • What are the tools in creating an animation?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!