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
Using the flowchart diagram, identifythe decision point of this solution?
ELEN [110]

Answer:

Is there an early pay discount?  

Explanation:

This determines and instructs what path the code should take,

if there is no early pay discount, it has different instructions to follow.

3 0
3 years ago
private int product(int n) { if(n &lt;= 1) return 1; else return n * product(n-2); } What is the output when product(6) is calle
sergeinik [125]

Answer:

48

Explanation:

In this code, there is a method i.e "product" of "int" type it means it returns the integer value. The description of the given code is given below

  • Initially when product(6) function is called the else block will be executed so return(6)*product(4).
  • As we saw that above product(4) is a recursion function " Function which calls itself again and again " . so again else block is executed now the value is return(6)*return(4) *return(2);

So it returns 48

7 0
3 years ago
PART ONE: For this assignment, create an html page that has a login form. The form should have 3 input elements -- 1. type text
Digiron [165]

Answer:

The following code are in HTML language:

Login_page.html :

<!DOCTYPE html>

<html lang="en">

<head>

<title>Login_Form</title>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1">

<link href="css/style.css" rel="stylesheet">

</head>

<body>

<form action="Login_page.php" method="post">

<table>

<tr>

<td>UserName</td>

<td>

<input type="text" name="username" placeholder="Username"/>

</td>

</tr>

<tr>

<td>Password</td>

<td>

<input type="password" name="password" placeholder="Password"/>

</td>

</tr>

<tr>

<td>

<input type="Submit" name="login" value="submit"/>

</td>

</tr>

</table>

</form>

</body>

</html>  

Explanation:

Here, we have to use the HTML tag, and HEAD tag and the TITLE tag for the title of the page.

Then, we have to create a table for the structure of Form page by using table tag.  

Then, we have to create form by using Form tag

Then, create two text boxes for the username and the password with the use of an input tag.

Then, we have to create a submit button for submitting the following details with the use of an input tag.

3 0
3 years ago
Many computers today use _____ which is a coding scheme using at least 16 bits to represent a character.
AnnyKZ [126]
Many computers today use unicode
3 0
4 years ago
If you wanted to evaluate a broken knee, you could use all of the following EXCEPT _____.
NeX [460]

Answer:

what are the options? Would love to help.

Explanation:

7 0
4 years ago
Other questions:
  • Pointers with classes a) A user-defined class named Timer has a constructor that takes two integer parameters to initialize hour
    14·1 answer
  • A desktop _______ produces creative digital designs with illustration software.
    12·1 answer
  • Why we can't install a 64 bit software on a 32 bit computer??
    5·1 answer
  • Write a static method named textcount that takes a scanner representing a file as a parameter and that reports various statistic
    11·1 answer
  • Which is the most effective manner to deliver a speech inmost business settings?extemporaneous presentationmemorizationreadingvi
    9·1 answer
  • Host A is a PC, connected to switch SW1 and assigned to VLAN 1. Which of the following are typically assigned an IP address in t
    13·1 answer
  • In Marvel Comics, what imaginary rare metal is an important natural resource of Wakanda, the home country of Black Panther?
    15·1 answer
  • Create a program to determine the largest and smallest number out of 15 numbers entered (numbers entered one at a time). This sh
    11·1 answer
  • Builder Software is used to create _____? answers: 3d digital art design for cameras audio special effects
    5·2 answers
  • In a program you need to store identification numbers of 5 employees and their weekly gross pay.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!