Write a function template that gets an array of generic type T as well as the number of items within the array, calculates the standard deviation of the items within the array and returns it. The user will first give an integerItemCount value (int) and that many integer values (all ints). Then, the user will give a doubleItemCount value (int) and that many double values (all doubles). Then, the program will use the function template to calculate the standard deviations of both arrays and print them out as first the standard deviation of the int array, then the standard deviation of the double array. Standard deviation of an array with size N, values are given as , and arithmetic mean as μ can be calculated as: Requirements: You MUST define and use a function template that takes an array of generic type T and an integer which defines the size of the array Getting all the user input, calling the appropriate version of the function via the template and printing the output should be done in the main() function. NOTE: The size of each array will be AT MOST 1000. You do NOT need to check this. NOTE: You can use the sqrt function of the cmath library to calculate the square root value. Input 3 5 6 7 6 1 2 3 4.5 6.2 0.6 6 5 67 2 -3 4 6 4 0 0.2 0.6 0.4 8 3 56 12 -7 0 0 3 6 5 -5.6 -2.1 -1.1 -0.8 6.54 Output 0.816497 1.96504 24.1074 0.223607 18.4289 3.9628

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Write a function template that gets an array of generic type T as well as the number of items within the array, calculates the standard deviation of the items within the array and returns it.

The user will first give an integerItemCount value (int) and that many integer values (all ints). Then, the user will give a doubleItemCount value (int) and that many double values (all doubles).

Then, the program will use the function template to calculate the standard deviations of both arrays and print them out as first the standard deviation of the int array, then the standard deviation of the double array.

Standard deviation of an array with size N, values are given as , and arithmetic mean as μ can be calculated as:

Requirements:

  • You MUST define and use a function template that takes an array of generic type T and an integer which defines the size of the array
  • Getting all the user input, calling the appropriate version of the function via the template and printing the output should be done in the main() function.

NOTE: The size of each array will be AT MOST 1000. You do NOT need to check this.

NOTE: You can use the sqrt function of the cmath library to calculate the square root value.

Input

3

5 6 7

6

1 2 3 4.5 6.2 0.6

6

5 67 2 -3 4 6

4

0 0.2 0.6 0.4

8

3 56 12 -7 0 0 3 6

5

-5.6 -2.1 -1.1 -0.8 6.54

Output

0.816497

1.96504

24.1074

0.223607

18.4289

3.9628

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY