Thread: Standard Deviation, etc.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Hint: 3/4 equals 0

    Tim S.

  2. #2
    Registered User
    Join Date
    Feb 2011
    Posts
    4
    Quote Originally Posted by stahta01 View Post
    Hint: 3/4 equals 0
    So do I need to make one of my ints into a float? any guidance here?

  3. #3
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Don't put your functions inside main.

    Quote Originally Posted by wovenhead View Post
    Line 21: error: called object 'sum' is not a function
    Why isn't sum a function?
    It is, but your local variable overrides the global symbol, so inside that function, sum is just a plain int. Rename it to total or some such.

    12: for(i=0, i < count, i ++)

    Line 12: error: expected ';' before ')' token
    Line 12: error: expected expression before ')' token

    what's wrong with for(i=0, i < count, i ++)
    You need a semicolons not commas.

    Quote Originally Posted by wovenhead View Post
    So do I need to make one of my ints into a float? any guidance here?
    Yes, since you're dividing it by count, which is another int, you end up with integer division, which is very inaccurate. Basically it divides and gives you the whole number part, discarding the remainder. You could change it to a float/double or just cast one of the two operands to a float or double.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C/C++ standard
    By confuted in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 07-06-2003, 03:22 AM
  2. Standard Deviation in C++
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 09-14-2001, 11:09 AM
  3. loops and I/O file.
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 09-09-2001, 09:41 AM
  4. standard language, standard compiler?
    By doubleanti in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 09-03-2001, 04:21 AM