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
A web page ____ can also create a style sheet that takes precedence over the internal style sheets of browsers.
posledela
This work can be done only by the creator of that web page. So i can recommend it will be 
creator / author
5 0
3 years ago
A motor is controlled by a logic circuit. The circuit has inputs (0 or 1) from three sensors
vivado [14]

Answer:

motor is controlled by a logic circuit. The circuit has inputs (0 or 1) from three sensors

R, T and W. The motor is switched off when the output from the logic circuit is 1. wym

6 0
3 years ago
Is orange named after the fruit or of the color?
Alexeev081 [22]
I slick thinks it’s because of its color
4 0
3 years ago
In modern computer memory, each location is normally composed of one byte.
Paraphin [41]
An actual parameter in a method call, or one of the values combined by an operator
4 0
3 years ago
Consider the following class definitions.
Serggg [28]

Answer:

The correct answer is option A

Explanation:

Solution

Recall that:

From the question stated,the following segments of code that should be used in replacing the /* missing code */ so that the value 20 will be printed is given below:

Android a = new Android(x);

a.setServoCount(y);

System.out.println(a.getServoCount());

The right option to be used here is A.

4 0
3 years ago
Other questions:
  • How can i put this sign in my keybord?<br><br> :::::<br> ^<br> Here is the sign
    8·1 answer
  • What is a block cipher algorithm that operates on 64-bit blocks and can have a key length from 32 to 448 bits?
    8·1 answer
  • To access WordPad, Jill will click on Start, All Programs, Accessories, and WordPad. To access Notepad, Karl will click on Start
    11·1 answer
  • A tornado may be approaching if you observe which of the following?
    15·1 answer
  • 1. You have recently been hired by a leading firm, which provides information management solutions to large corporations. As a n
    12·2 answers
  • Help giving points mark BRAINLEST
    5·1 answer
  • Which line of code outputs the decimal portion of a float stored in the variable x? print (x % 1000) print (x) O print (x / 1000
    13·1 answer
  • NO LINKS OR SPAMS THEY WILL BE REPORTD<br><br> Click here for 50 points
    5·2 answers
  • How much would it cost to get the screen replaced on a Moto G7?
    10·1 answer
  • Write any two disadvantage of First generations computers​
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!