1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Standart deviation in c

  1. Mar 31, 2008 #1
    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: Mar 31, 2008
  2. jcsd
  3. Apr 1, 2008 #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.
  4. Apr 1, 2008 #3
    no way you should be doing any statistical programming without using arrays/lists/something like that.
  5. Apr 3, 2008 #4
    I figured it out now ,instead of saving inputs separately by using arrays, I can convert deviation formula another form


    Now , it's easy to calculate. Thanks
  6. Apr 3, 2008 #5

    D H

    User Avatar
    Staff Emeritus
    Science Advisor

    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).
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook