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
What is the first thing animators need to determine when beginning a project?
tatuchka [14]

Answer:c

Explanation:

8 0
2 years ago
List pros and cons of HCI technology​
Verdich [7]
A pro of HCI technology is that its user friendly and a con about it is that you have to teach the user what to do or guide them!
8 0
2 years ago
Read 2 more answers
Which of the following is not a language commonly used for web programming?
DerKrebs [107]
The answer would be Assembly language as assembly language is not used for web development, but rather is a low level programming language.

Please mark branliest if this helped!!
7 0
3 years ago
Read 2 more answers
Consider a set of mobile computing clients in a certain town who each
poizon [28]

Answer: answer given in the explanation

Explanation:

We have n clients and k-base stations, say each client has to be connected to a base station that is located at a distance say 'r'. now the base stations doesn't have allocation for more than L clients.

To begin, let us produce a network which consists of edges and vertex

Network (N) = (V,E)

where V = [S, cl-l, - - - -  cl-n, bs-l - - - - - - bs-k, t]

given that cl-l, - - - - - cl-n represents nodes for the clients

also we have that bs-l, - - - - - bs-k represents the nodes for base station

Also

E = [ (s, cl-i), (cl-i,bs-j), (bs-j,t)]

(s, cl-i) = have capacity for all cl-i (clients)

(cl-i,bs-j) = have capacity for all cl-i  clients & bs-j (stations)

⇒ using Fond Fulkorson algorithm we  find the max flow in N

⇒ connecting cl-i clients to  bs-j stations

      like (cl-i, bs-j) = 1

   if f(cl-i, bs-j)  = 0

⇒ say any connection were to produce a valid flow, then

if cl-i (clients) connected                f(s,cl-i) = 1 (o otherwise)

if cl-i (clients) connected  to bs-j(stations)   f(cl-i,bs-j) = 1 (o otherwise)

   f(bs-j,t) = no of clients  (cl-i)  connected to bs-j

⇒ on each node, the max flow value (f) is longer than the no of clients that can be connected.

⇒ create the connection between the client and base station i.e. cl-l to base bs-j iff    f(cl-i, bs-j) = 1

⇒ when considering the capacity, we see that any client cannot directly connect to the base stations, and also the base stations cannot handle more than L clients, that is because the load allocated to the base statsion is L.

from this, we say f is the max no of clients (cl-i) that can be connected if we find the max flow, we can thus connect the client to the base stations easily.

cheers i hope this helps

5 0
3 years ago
3.1.2 Quiz: What Can Information Technology Do for You? Question 8 of 10 What is one reason why a business may want to move enti
balu736 [363]

Answer:

C. To focus on a global market

Explanation:

Information technology can be defined as a set of components or computer systems, which is used to collect, store, and process data, as well as dissemination of information, knowledge, and distribution of digital products.

An information technology interacts with its environment by receiving data in its raw forms and information in a usable format.

Generally, it is an integral part of human life because individuals, organizations, and institutions rely on information technology and systems in order to perform their duties, functions or tasks and to manage their operations effectively. For example, all organizations make use of information technology and systems for supply chain management, process financial accounts, manage their workforce, and as a marketing channels to reach their customers or potential customers.

Additionally, an information system or technology comprises of five (5) main components;

1. Hardware.

2. Software.

3. Database.

4. Human resources.

5. Telecommunications.

Hence, information technology or system relies on the data it receives from its environment, processes this data into formats that are usable by the end users.

One reason why a business may want to move entirely online is to focus on a global market through the use of social media platforms and networks to reach out to customers in various geographical location.

5 0
2 years ago
Other questions:
  • Henry uploaded the photos of his birthday to a cloud storage system. He feels that it’s a safe option for data storage. His frie
    12·1 answer
  • How do you know if you get a phone call that is a scam
    8·2 answers
  • The last 64 bits of an ipv6 address are the interface identifier. what is frequently used to specify the interface identifier?
    14·1 answer
  • . double x = 5; declares that x is a...............variable.
    14·1 answer
  • Write the method addItemToStock to add an item into the grocery stock array. The method will: • Insert the item with itemName ad
    12·1 answer
  • Write a function definition for a function which takes one parameter and returns twice that parameter
    12·1 answer
  • O O O O O O O
    9·1 answer
  • Give 5 comparisons of the three employees with the highest net pay
    5·2 answers
  • Write a program to prompt the user for hours worked to compute a gross pay for an employee, and he is paid 100/hour. If he worke
    7·1 answer
  • These days, a digital signature is just as legitimate and trusted as an old-fashioned John Hancock on paper.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!