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
Given the following schedule, show the locks that will occur and the subsequent schedule. Assume that strict 2PL is in effect, w
Alexxandr [17]

Answer:

see explaination

Explanation:

Please kindly check attachment for the step by step solution of the given problem

4 0
3 years ago
With modeling and simulation, we model the system and then test the ______________ to gather test predictions.
Kobotan [32]

Answer:

With modeling and simulation, we model the system and then test the system to gather test predictions.

Explanation:

You would have to test the system in order to see if it's working right and everything is all good with the system.

I hope this helped. I am sorry if you get this wrong.

4 0
3 years ago
The AND operator is a disjunction and the OR operator is a conjunction.
qwelly [4]

Answer:

True but it might be false but i think is true

8 0
2 years ago
Write 'T' for true and 'F' for false statements.
asambeis [7]
1-F
2-T
3-F
4-F
5-F
6 T
7-T
3 0
2 years ago
Hypertension occurs when blood pressure is too high.
Ivan
True, hypertension is when your blood pressure is to high.
Please mark as brainliest
8 0
3 years ago
Other questions:
  • Assume the following representation for a floating point number 1 sign bit, 4 bits exponent, 3 bits for the significand, and a b
    9·1 answer
  • Due to the absorption and scattering of shorter wavelengths by interstellar dust, distant stars appear A) bluer. B) brighter. C)
    9·1 answer
  • Application Software include programs like: MS Word, Google Docs, MS Exce ect...
    13·1 answer
  • Given the following business scenario, create a Crow's Foot ERD using a specialization hierarchy if appropriate. Granite Sales C
    12·1 answer
  • Viruses which activate themselves after a specific time is called
    10·2 answers
  • Which of the following represents a bit?<br><br> 0<br><br> 01010110<br><br> 3F02C<br><br> 12.356
    12·1 answer
  • Giving brainliest if you answer question.
    8·1 answer
  • _____ is rampant with bugs and shortcomings because most programmers do not know how or do not take the time to incorporate secu
    14·1 answer
  • What are the disadvantages of vector images when compared to bitmap images?
    14·1 answer
  • Which cloud technology characteristic ensures that a cloud customer can make changes to her cloud database from her smartphone w
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!