Question

write a program code that asks the user how many numbers they wish to find the...

write a program code that asks the user how many numbers they wish to find the statistics of and then asks the user to enter those numbers. The program must then calculate and display the average variance and standard deviation of the numbers entered by the user.

the program code must

-ask three user how many numbers they wish to find the statistics of

-ask the user to enter those numbers and store them in an array

- use a loop to calculate the average of those numbers

-use a loop to calculate the variance of the numbers

- calculate the standard deviation of the numbers

- display the average , variance , and standard deviation of the numbers  

0 0
Add a comment Improve this question Transcribed image text
Answer #1

here I use c language for writing the code

find average of the numbers

find variance of the numbers

find standard deviation

Average of the numbers:

the sum of all the numbers stored in the array. divided the sum by total number of elements

variance: the average of the squared differences from the mean

the formula for variance:  ∑ [array[i] - average]]/(n)

standard deviation: it is a measure of variation or dispersion of a set of values

it is calculated the square root of the variance

formula : squate_root(variance)

code :

#include <stdio.h>
#include <math.h>

void
main ()
{
float array[100];
int i, n;
float average, variance, Standard_deviation, sum = 0, sum1 = 0;

printf ("how many numbers they wish to find the statistics of: \n");
scanf ("%d", &n);
printf ("the user to enter those numbers:\n");
for (i = 0; i < n; i++)
{
scanf ("%f", &array[i]);
}
//the values of the array
printf ("the numbers in the array:");
for (i = 0; i < n; i++)
{
printf ("%6.1f", array[i]);
}
printf ("\n");
// find average of the numbers
for (i = 0; i < n; i++)
{
sum = sum + array[i];
}
average = sum / (float) n;

//find the variance of the numbers
for (i = 0; i < n; i++)
{
sum1 = sum1 + pow ((array[i] - average), 2);
}
variance = sum1 / (float) n;

//find the Standard deviation
Standard_deviation = sqrt (variance);

//display the result

printf ("Average of all the numbers = %.2f\n", average);
printf ("variance of all the numbers = %.2f\n", variance);
printf ("Standard deviation = %.2f\n", Standard_deviation);
}

output:

Add a comment
Know the answer?
Add Answer to:
write a program code that asks the user how many numbers they wish to find the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Design a program that asks the user to enter a series of 20 numbers. The program...

    Design a program that asks the user to enter a series of 20 numbers. The program should store the numbers in the array and then display the following data: The lowest number in the array The highest number in the array The total of the number in the array The average of the numbers in the array PLEASE GIVE THE PSEUDOCODE AND CODE IN C PROGRAMMING

  • Create a Java program which asks the user how many names they want to enter. The...

    Create a Java program which asks the user how many names they want to enter. The program should then instantiate an array that will hold this many names. The main method should call a method, getNames() to allow the user to enter the names. A for loop should be used in this method. Once the names are entered, the main method should call another method displayNames() which will use a while loop to display the names entered.

  • Java Code Help! Code this: Calculate statistics. Write a class called Statistics that can calculate a...

    Java Code Help! Code this: Calculate statistics. Write a class called Statistics that can calculate a number of properties about an array of doubles. There should be separate static methods to calculate the min, the max, the mean, the median, the standard deviation (make sure to make use of your mean method to implement this), and the mode. For the mode, you can assume that the data set is not multimodal. This class should not have a main method. Write...

  • Write a C program that asks the user to enter two real numbers. Then your program...

    Write a C program that asks the user to enter two real numbers. Then your program displays a menu that asks the user to choose what arithmetic operation to be done on those numbers. Depending on the user's entry, the program should display the result to the screen. The sample runs below show what should be done to the numbers entered by the user. Your program should run exactly like shown in the sample runs. make your code run as...

  • C programming Ask the user how many numbers they would like generated. Your program will then...

    C programming Ask the user how many numbers they would like generated. Your program will then generate that many numbers (between 0 and 1000, inclusive) into an array of the same size. Find the smallest and largest numbers in the array, printing out the values and locations of those numbers in the array. Then, find the sum and average of the numbers in the array. Finally, print out the entire array to verify. You MUST use functions where appropriate!

  • Write a program and flowchart. The program should ask the user how many customers they want to track. Then, it asks for customer numbers, and sales by customer. At the end, it prints out the customer...

    Write a program and flowchart. The program should ask the user how many customers they want to track. Then, it asks for customer numbers, and sales by customer. At the end, it prints out the customer number, the customer sales, and then the total sales and average sales. You must use two different arrays, one for customer number, and one for sales. These are, in effect, parallel arrays.   You must use a "while" loop to gather customer number and sales....

  • Write a program that calculates the average of a stream of non-negative numbers. The user can...

    Write a program that calculates the average of a stream of non-negative numbers. The user can enter as many non-negative numbers as they want, and they will indicate that they are finished by entering a negative number. For this program, zero counts as a number that goes into the average. Of course, the negative number should not be part of the average (and, for this program, the average of 0 numbers is 0). You must use a method to read...

  • Write a console-based program ( C # ) that asks a user to enter a number...

    Write a console-based program ( C # ) that asks a user to enter a number between 1 and 10. Check if the number is between the range and if not ask the user to enter again or quit. Store the values entered in an array. Write two methods. Method1 called displayByVal should have a parameter defined where you pass the value of an array element into the method and display it. Method2 called displayByRef should have a parameter defined...

  • java programming!!! Write the code fragment that will do the following: • Ask the user how...

    java programming!!! Write the code fragment that will do the following: • Ask the user how many numbers they want to enter • Declare and instantiate an array of doubles with as many elements as the number entered by the user • Write one 'for' loop to fill the array with data from the user • Write a second 'for' loop to calculate the sum of all of the numbers in the array • Print the calculated sum Note: Write...

  • Write a program and flowchart. The program should ask the user how many customers they want...

    Write a program and flowchart. The program should ask the user how many customers they want to track. Then, it asks for customer numbers, and sales by customer. At the end, it prints out the customer number, the customer sales, and then the total sales and average sales. You must use two different arrays, one for customer number, and one for sales. These are, in effect, parallel arrays.   You must use a "while" loop to gather customer number and sales....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT