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 large retailer is asking each customer at checkout for their zip code. if the zip code is the only recorded variable, what is
Varvara68 [4.7K]

Answer:

Nominal

Explanation:

  • So while singing the question, let's further move to the answer. So let's see here and there.
  • The first option is B. S, which corrects gross sectional data, And the 2nd 1 of Nominal, C. Is correct nominal. So here are the buddha points which are given in the question.
  • The first one, option B is correct cross-sectional data, And the 2nd 1, is option C. Is correct nominal.

To learn more about it, refer

to brainly.com/question/25458754

#SPJ4

7 0
2 years ago
Name the part of the computer that stores all information and software.
Paladinen [302]

Answer:

Hard Drive

Explanation:

8 0
3 years ago
Read 2 more answers
Hazel has just finished adding pictures to her holiday newsletter. She decides to crop an image. What is cropping an image?
Ilya [14]
B) cutting off part of the image

hope it helps
3 0
3 years ago
bookmark question for later what database did zach choose? microsoft excel microsoft access db2 oracle
Veronika [31]

Zach chooses the databases is Oracle

<h3>Explain about the databases?</h3>

Information that is organized into a database is made available for quick administration, updating, and access. Network databases, object-oriented databases, and hierarchical databases are all types of databases.

According to the TOPDB Top Database index, Oracle is the most widely used database with 32.09% of the market share. Computer databases often hold collections of data records or files containing information, such as sales transactions, customer data, financials, and product information My SQL, with a score of 16.64, is in second place, while SQL Server, with a score of 13.72 percent, is third. Since at least 2006, Oracle has dominated global database searches, making it the most used database not just in 2022.

To learn more about databases refer to:

brainly.com/question/28255661

#SPJ4

5 0
1 year ago
what is the the process of sending a packet from one host to a selected group of hosts, possibly in different networks?
Burka [1]
I believe it's "multicast"
6 0
3 years ago
Other questions:
  • What is computer virus?
    8·1 answer
  • Write a main method that prompts the user for an integer between 1 &amp; 20 (inclusive). If the user enters an invalid number, p
    8·1 answer
  • The main workplace of a Windows computer is called the
    14·1 answer
  • You are troubleshooting a laptop with multiple sticking keys that result in misspelled words while the user types. Other than se
    10·1 answer
  • This morning when Paul turned on his computer at work, it would not boot. Instead, Paul reported that he heard a loud clicking n
    12·1 answer
  • A non technical kind of cyber intrusion that relies heavily on human interaction and often involve tricking people into breaking
    5·1 answer
  • What are some disadvantages of using a word processor over a type writer?​
    7·1 answer
  • What is the safest way to pay online​
    13·2 answers
  • Write a program that computes how much each person in a group needs to pay (after tax and tip) when splitting the bill equally.
    5·1 answer
  • After inserting a video into your slide how can you test it
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!