Calculate Standard Deviation & More: Keyboard Input Program without Arrays

  • Thread starter Thread starter blu3jam
  • Start date Start date
  • Tags Tags
    deviation
Click For Summary

Discussion Overview

The discussion revolves around writing a program to calculate statistical measures such as the largest, smallest, average, standard deviation, and sum of numbers entered via keyboard input, specifically without using arrays. Participants explore the feasibility and implications of this approach, considering the use of a sentinel value to terminate data entry.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant questions the possibility of writing the program without arrays, seeking suggestions.
  • Another participant argues that using arrays would simplify the process, especially for handling a large number of inputs, suggesting that it would be impractical to define each variable manually.
  • A third participant strongly asserts that statistical programming should not be done without arrays or similar data structures.
  • A later reply indicates that the original poster has found an alternative method to calculate standard deviation without arrays, implying a reformulation of the deviation formula.
  • Another participant raises a concern about the potential inaccuracy of calculations performed without arrays, noting that numerical precision issues may arise when using standard data types in programming languages like C.

Areas of Agreement / Disagreement

Participants generally disagree on the necessity of using arrays for this programming task, with some advocating for their use due to practical considerations, while others explore alternative methods. The discussion remains unresolved regarding the best approach to take.

Contextual Notes

Participants express concerns about numerical precision and the limitations of using standard data types in programming, highlighting potential inaccuracies in calculations without arrays.

blu3jam
Messages
7
Reaction score
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
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.
 
no way you should be doing any statistical programming without using arrays/lists/something like that.
 
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
 
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).
 

Similar threads

Replies
7
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
9
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 13 ·
Replies
13
Views
2K