Calculating an average [was Re: Summary of loops]

From: Anthony Borla (ajborla_at_bigpond.com)
Date: 02/22/05


Date: Tue, 22 Feb 2005 11:12:42 GMT


<claradona@hotmail.com> wrote in message
news:1109068051.789292.213810@g14g2000cwa.googlegroups.com...
> Hi,
>
> I am stumped here. Been stuck doing this program and
> cant seem to debug the errors! Can someone pls help me?
> How do I calculate the totals of the computation in a loop
> and later display those averages as a summary outside the
> loop?
>
> much help is appreciated.
>

Mmm ! This question seems familiar ;) !!! Here's a very rough example:

    double sum = 0.0;

    for (int i = 0; i < MAX_ITERATIONS; i++)
    {
         ...
         sum += ...;
         ...
    }

    double average = sum / i;

    // Display the average, and whatever else ...
    // ...

You're likely to learn much more if you try to solve the problem yourself.

I hope this helps.

Anthony Borla



Relevant Pages

  • Re: help: why dosent this code work?
    ... > infinite loop:( ... it is stuck waiting on a semaphore that I never saw anyone signal. ... And that appears to be an infinite busy loop. ... Go and debug your code - first find where you are stuck. ...
    (comp.os.linux.misc)
  • Summary of loops
    ... Been stuck doing this program and cant seem to debug ... How do I calculate the totals of ... the computation in a loop and later display those averages as a summary ...
    (comp.lang.java.help)
  • Combinations of sets
    ... Anyone know how i can write this code if i dont know the number of ... In my working example each set will represent a loop. ... is that i cant say there is 3 sets, there could be 4,5 or whatever. ... Im stuck on this:( ...
    (alt.comp.lang.borland-delphi)
  • Object reference not set to an instance of an object
    ... But when i debug, i cant find out ... Really stuck): The exception comes on the if statement. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Calculating an average [was Re: Summary of loops]
    ... Anthony Borla wrote: ... Been stuck doing this program and ... >>cant seem to debug the errors! ...
    (comp.lang.java.help)