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]
2 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]2 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
Dwight <br> d. eisenhower was impressed with germany's network of highways and how it __________.
emmasim [6.3K]
Eased the mobilization and transportation of troops
5 0
2 years ago
Which of the following is not a negative environmental effect associated with cars? A. Deforestation B. Roadside litter C. Toxic
777dan777 [17]

Answer:

The answer to this question is the option "C".

Explanation:

In this question, the answer is option C. Which is river toxic pollution. This pollution is also known as Kim Kim river toxic pollution. In 2019 this pollution occurred in the water caused by unauthorized chemical garbage dumping in the river in Malaysia. The unauthorized dumping released poisonous fumes, affecting six thousand people are hospitalized in 2,775.

8 0
3 years ago
Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binar
MAXImum [283]

Answer:

thats what i was about to ask. im not sure

Explanation:

sorry   '-'

3 0
2 years ago
​Five elements that can prove the genuineness of a user. What you know, what you have, what you are, what you do, and where you
nataly862011 [7]

Authentication factors are the factors that describe about the ingenuition or origination of the user. This is the tag that tells about the actuality of user that is getting connected with internet by the five elementals.

Hope this helps!

8 0
3 years ago
Ian’s photography teacher asks him to take some photos of a few different species over the weekend. Which group of photos would
alina1380 [7]
I think it’s b or d..............
5 0
3 years ago
Other questions:
  • Tomi is testing all of the links on her web page by clicking on each one in a browser. What type of testing is this considered?
    6·2 answers
  • 20 points/ When creating a storyboard, in which section do you mention how you move from one shot to the next?
    11·1 answer
  • A base class named Garden contains a private field width and a property public int Width that contains get and set accessors. A
    11·1 answer
  • What are some examples of lighter-than-air vehicles?
    10·1 answer
  • You are informed that all the users within the network are unable to access the Internet. You decide to start troubleshooting fr
    12·1 answer
  • HELP ME PLZ QUICK Adam is writing a program that: 1) has the user guess a number, and 2) tells the user how many guesses it took
    11·1 answer
  • What is the base for a hexadecimal number system?
    11·1 answer
  • What icon is usually used to indicate an attachment feature?
    14·2 answers
  • Create an online order form for a car rental store and include the following items: input text box to enter the number of days i
    14·1 answer
  • Which of the following is a characteristic of vector graphics?
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!