Thread: Quick Understanding Question

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    42
    I am not challenging you. But I dont understand why I have to do that? What tells you that you have to calculate it outside of the loop? Am I missing something?

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    835
    Quote Originally Posted by leopardforest@g View Post
    I am not challenging you. But I dont understand why I have to do that? What tells you that you have to calculate it outside of the loop? Am I missing something?
    When you calculate an average, it's easier (but not necessary) to compute the sum, and only then divide by the number of elements, once. BTW, you've written the function to assume that the number of elements is 5. You could pass the number of elements as another argument, and then divide by whatever it is.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Very quick math question
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 10-26-2005, 11:05 PM
  2. very quick question.
    By Unregistered in forum C++ Programming
    Replies: 7
    Last Post: 07-24-2002, 03:48 AM
  3. quick question
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 07-22-2002, 04:44 AM
  4. Quick Question Regarding Pointers
    By charash in forum C++ Programming
    Replies: 4
    Last Post: 05-04-2002, 11:04 AM
  5. Quick question: exit();
    By Cheeze-It in forum C Programming
    Replies: 6
    Last Post: 08-15-2001, 05:46 PM