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
erma4kov [3.2K]
3 years ago
10

(Statistics) Write a program that includes two functions named calcavg() and variance(). The calcavg() function should calculate

and return the average of values stored in an array named testvals. The array should be declared in main() and include the values 89, 95, 72, 83, 99, 54, 86, 75, 92, 73, 79, 75, 82, and 73. The variance() function should calculate and return the variance of the data. The variance is obtained by subtracting the average from each value in testvals, squaring the values obtained, adding them, and dividing by the number of elements in testvals. The values returned from calcavg() and variance() should be displayed by using cout statements in main().
Computers and Technology
1 answer:
Gwar [14]3 years ago
7 0

Answer:

Following are the program in the C++ Programming Language.

#include<iostream>   //set header file

using namespace std;  //namespace

//set method for sum and average

double calcavg(int a[])  

{

double t=0;  

double average ;

  cout<<"Arraylist is : "<<endl;

for(int i=0;i<14;i++) //set for loop

{ cout<<a[i]<<" ";

  t = t+a[i];

}

cout<<endl<<endl;

  average = t/14;

  cout<<"total : "<<t<<endl; //print message with output

return average; //return the average

}

//set method for the variance

double variance(int a[],double average)  

{

  double t=0;

for(int i=0;i<14;i++) //set the for loop

{

      a[i] = (a[i]-average) * (a[i]-average);

  t = t+a[i];

}

  double variance = t/14;

  return variance; // return variance

}

int main() //define main method

{

  double average;

  double variances ;

  //set array data type declaration

  int testvals[]={89,95,72,83,99,54,86,75,92,73,79,75,82,73};  

  average = calcavg(testvals); //call the methods

  variances = variance(testvals,average); //call the methods

  cout<<"average is : "<<average<<endl; //print output

  cout<<"variance is : "<<variances<<endl;//print output

  return 0;

}

<u>Output</u>:

Arraylist is :

89 95 72 83 99 54 86 75 92 73 79 75 82 73

total : 1127

average is : 80.5

variance is : 124.429

Explanation:

Here, we set the function "calcavg()" in which we pass integer data type array argument "a[]" in its parameter.

  • inside it, we set two double type variable "t" and assign its value to 0 and "average"
  • we set the variable "t" to find the total sum of the array
  • we set the variable "average" to find the average of the array.

Then, we set the function "variance()" in which we pass two argument, integer array type argument "a[]" and double type argument "average" in its parameter.

  • inside it, we find the variance of the array.

Finally, we define the "main()" function in which we call both the functions and pass values in its argument and then print the output.

You might be interested in
Small data files that are deposited on a user's hard disk when they visit a website are called _______.
IrinaK [193]
The answer is cookies
7 0
3 years ago
Read 2 more answers
Jenna wants to convert a decimal number to its octal form. Which option will she use to calculate the octal number?
Gelneren [198K]

Answer and Explanation

Needs  to 'multiply' a number by the base value 8 in octal.

To convert from octal to decimal, make a table of base 8 multipliers.  

8⁵ = 32,768  

8⁴ = 4,096  

8³ = 512  

8² = 64  

8¹ = 8  

8⁰ = 1

Octal number system is the base of -8 number system which uses the digits zero to seven. while decimal numbers  or decimal system uses the positional numeral system 0-9. . It also requires a dot (decimal point) to represent decimal fractions.

6 0
3 years ago
1.what is a computer?
Amanda [17]
1. an electronic device for storing and processing data, typically in binary form, according to instructions given to it in a variable program.
2. a peripheral device, as a keyboard or stylus, used to enter data into a computer for processing.
3. Output is defined as the act of producing something, the amount of something that is produced or the process in which something is delivered. An example of output is the electricity produced by a power plant. An example of output is producing 1,000 cases of a product.

4. A system unit is the part of a computer that houses the primary devices that perform operations and produce results for complex calculations. It includes the motherboard, CPU, RAM and other components, as well as the case in which these devices are housed.
8 0
3 years ago
Which of these is an effective color scheme?
irga5000 [103]

Answer:

Yellow on white.

Explanation:

Not to bright, soft, and easy to see.

4 0
3 years ago
The seven basic parts of a computer are
True [87]
Monitor, keyboard, CPU, mouse, and I believe the USB drive , DVD drive and hardware system
4 0
3 years ago
Read 2 more answers
Other questions:
  • List any four routes of transmission of computer virus. <br>please give me answer​
    8·1 answer
  • The distance at which wi-fi signals can travel ranges typically between ____ and ____.
    15·1 answer
  • To illustrate a point in a Word document with a simple chart, what commands should you select?
    8·2 answers
  • what is the first step you would take when troubleshooting an external network, such as an internet connection issue?
    13·2 answers
  • 2. Design a class named Sandwich with data fields for description and price. Include a constructor that requires arguments for b
    14·1 answer
  • Sayeed needs to ensure that his manager is up to date on his progress and wants to send a Status Report for a particular task. I
    11·2 answers
  • Shira’s Shoes sold 875,000 pairs of sandals in June, which was 70% of the total number of shoes sold. How many shoes did the com
    14·2 answers
  • Which data type is –7?<br><br> int<br><br> single<br><br> string<br><br> float
    15·1 answer
  • What is Accenture's role in Multi-party Systems?
    12·1 answer
  • bailey reads wikis at the beginning of his research project to get his bearings on the topic. he switches to peer-reviewed journ
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!