Calculate Standard Deviation & More: Keyboard Input Program without Arrays

  • Thread starter blu3jam
  • Start date
  • Tags
    deviation
In summary, the conversation discusses writing a program to find and display the largest, smallest, average, standard deviation, and sum of all numbers entered from the keyboard. The use of arrays is suggested as it makes the process easier and more efficient, especially when dealing with a large number of values. However, one person suggests using a different formula for standard deviation instead of using arrays. This is deemed easier, but may result in less accuracy due to computer precision limitations.
  • #1
blu3jam
7
0
Write a program to find and display the Largest, Smallest, Average, standard deviation and the Sum of all numbers entered from the keyboard.The data entry should end with a Sentinel Value. After finishing ask if the user wants to continue entering new set of numbers or not.

hw1.ht1.gif
, where X indicates average
My question is can we write this program without using arrays ? Does anybody have a suggestion ?
 
Last edited:
Physics news on Phys.org
  • #2
Not really. It will make your life easier to use arrays. It will help if there is a known number of samples, perhaps you can ask the user before you create the array and then once you know the value, create it with that many locations.

Also, it's A TON easier to go through hundreds or even thousands of x values with an array (using either a for or while loop). Imagine wanting to store 4,000 x values. That means you need 4,000 manually defined variables. Manually, as in you type x_1, x_2, x_3, ..., x_3999, x_4000.

Use an array. Use loops. This will make your life easier.
 
  • #3
no way you should be doing any statistical programming without using arrays/lists/something like that.
 
  • #4
I figured it out now ,instead of saving inputs separately by using arrays, I can convert deviation formula another form

52af1f8f6cb9c93b9ce829b3ac57af8f.png

9c3cd5442f1745f7f7ee2cff3174a6e0.png


Now , it's easy to calculate. Thanks
 
  • #5
Easy to calculate, but potentially inaccurate. Computers don't have infinite precision. What you did works mathematically but loses accuracy when performed using numbers as typically represented on computers (e.g., doubles or floats in the C language).
 

FAQ: Calculate Standard Deviation & More: Keyboard Input Program without Arrays

What is standart deviation in c?

Standard deviation in c is a statistical measure of how spread out a set of data is from the mean. It is calculated by finding the square root of the variance, which is the average squared difference of each data point from the mean.

Why is standard deviation important?

Standard deviation is important because it helps to understand the variability or dispersion of a dataset. It can also be used to compare the spread of data between two or more groups, or to identify outliers in a dataset.

How do you calculate standard deviation in c?

To calculate standard deviation in c, you will need to first calculate the mean of the dataset. Then, for each data point, subtract the mean and square the result. Next, find the average of these squared differences. Finally, take the square root of this average to get the standard deviation.

What is the difference between standard deviation and variance?

Standard deviation and variance are both measures of data variability, but they differ in their units of measurement. Standard deviation is measured in the same units as the data, while variance is measured in squared units. Additionally, standard deviation is more commonly used as it is easier to interpret and compare.

How does standard deviation relate to the normal distribution?

The normal distribution, also known as the bell curve, is a probability distribution that is commonly found in nature and many real-world phenomena. Standard deviation plays a key role in the normal distribution, as it determines the spread of the data around the mean. The larger the standard deviation, the wider the bell curve will be, and vice versa.

Similar threads

Replies
3
Views
1K
Replies
5
Views
2K
Replies
1
Views
3K
Replies
9
Views
4K
Replies
1
Views
2K
Replies
13
Views
2K
Back
Top