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
In cell I5, enter a formula to calculate the total admission fees collected for the 2018
V125BC [204]
The formula is to calculate the total admission fees collected is = F5*B14

1. Click on cell I5
2. Type equal sign =
3. Type F5 or click on F5 cell
3. Type multiplication sign *
4. Type B14 or click on B14 cell
4 0
3 years ago
Read 2 more answers
The cost of an items is Rs 200. what will be the cost of 50 such items. write a simple program​
alexandr402 [8]

Answer:

In Python:

Unit_Cost = 200

Cost50 = 50 * Unit_Cost

print("Cost of 50 items: Rs."+str(Cost50))

Explanation:

This initializes the unit cost to 200

Unit_Cost = 200

This calculates the cost of 50 of such items

Cost50 = 50 * Unit_Cost

This prints the calculated cost

print("Cost of 50 items: Rs."+str(Cost50))

4 0
2 years ago
What pattern is a heart-shaped pattern that captures sound from a single direction, ?from the front?
STatiana [176]

Answer:

The pickup diagram for the Cardioid (heart-shaped) microphone pattern tells you is that the microphone is most sensitive to sound coming in from the front (where the blue arrow is), and will tend to “refuse” sound coming in from the other side (the red arrow points to that part).

Explanation:

5 0
3 years ago
State 5 different between mouse and keyboard​
Gekata [30.6K]

Answer:

*here you go *

Explanation:

While the main purpose of a mouse is to guide the cursor on the computer monitor, a keyboard is a typewriter like device with some additional functions that allow human interaction with computer. ... While mouse is considered to be a pointing device, keyboard is the input device for a computer.

(Keyboard vs Mouse

Keyboard and mouse are integral parts of a computer system and one cannot even think of interacting with the computer or monitor with the use of these two devices. In a sense, these two devices are the user interface that allows working on a computer system, and without them it is not possible to do anything on a computer. While the main purpose of a mouse is to guide the cursor on the computer monitor, a keyboard is a typewriter like device with some additional functions that allow human interaction with computer. In fact, a keyboard is the only source of providing the input to the computer and it performs the functions we ask it only with the help of this device.

While mouse is considered to be a pointing device, keyboard is the input device for a computer. Despite touch screen having been developed that allows one to use virtual keyboard onscreen, physical keyboard remains first choice of most of the individuals. There are keys with symbols printed on them in a keyboard and with the lightest of touches; the numeral or alphabet gets written on the screen of the monitor using a keyboard. There are some instructions for which one has to press a key and holding it pressed, another key has to be pressed. There are many shortcuts also used with the help of a keyboard that help save time and effort. Many computer commands are the results of these shortcuts. The major function of a keyboard is when one is using a word processor or a text editor.

A mouse is a pointing device and consists of a right and left clicks with a wheel in between that allows on to scroll up and down on a web page. The major function of a mouse is to control the cursor on the monitor of the screen. Today there are wireless mouse available that work through infrared rays.)

6 0
3 years ago
PLEASE HELP ASAP!!
Anastasy [175]

What language are you programming in.

5 0
3 years ago
Other questions:
  • Connected contacts require___ to open.
    11·1 answer
  • Under which menu option of a word processing program does a star
    15·1 answer
  • While in an interactive nslookup session, you'd use the ______ keyword to change the DNS server you're using
    5·2 answers
  • You are given n sorted sequences each one containing n keys. You may assume n is a power of two. We want to merge them into one
    15·1 answer
  • How can an individual find career data?
    13·1 answer
  • The action in which a router divides and forwards incoming or outbound message traffic to multiple links is known as
    15·1 answer
  • Linda is training to become a certified network design expert and consultant. While researching about the process of cellular ra
    12·1 answer
  • Code works, need help writing header file.
    8·1 answer
  • Complete the implementation of the following methods:__init__hasNext()next()getFirstToken()getNextToken()nextChar()skipWhiteSpac
    11·1 answer
  • Define the term hardwar<br><br>​
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!