Re: Summary of loops

From: Clara (claradona_at_hotmail.com)
Date: 02/23/05


Date: 23 Feb 2005 03:58:11 -0800


"Anthony Borla" <ajborla@bigpond.com> wrote in message news:<qiPSd.171631$K7.29083@news-server.bigpond.net.au>...
> "Tilman Bohn" <myfirstname@gmx.net> wrote in message
> news:slrnd1mjcf.8o5.myfirstname@urizen.tilmanbohn.com...
> > In message <421b445a$0$12384$3b214f66@tunews.univie.ac.at>,
> > Daniel Tahin wrote on Tue, 22 Feb 2005 15:40:26 +0100:
> >
> > > Anthony Borla wrote:
> > [...]
> > >> for (int i = 0; i < MAX_ITERATIONS; i++)
> > >> {
> > >> ...
> > >> sum += ...;
> > >> ...
> > >> }
> > >>
> > >> double average = sum / i;
> > [...]
> > >
> > > There is only a bit problem:-) i is declared in the body of
> > > for(), so it's accessible only in it.
> > > If you want to reach it outside for(), you should declare
> > > it above for()!
> > >
>
> Sshhh - don't spoil the surprise ;) !
>
> >
> > I suspect he left the error as an exercise for the reader
> > (because he didn't want to do someone else's homework)
> > -- however, you've spotted the wrong error (or the wrong
> > fix if you prefer).
> >
>
> I'm hoping the post works like this:
>
> * Student Googles for 'Calculating an Average' [the
> reason behind changing the subject name was to
> make it more easily found in archive searches]
>
> * Post found - contains relevant Java code
>
> * Attempt to utilise code is made, *but*, it doesn't
> quite work ! Hopefully *now* the learning begins
>
> Who said homework was meant to be easy ;) !
>
> Cheers,
>
> Anthony Borla

Haha thanks a lot but it wasn't a piece of homework. I'm helping my
dad write and test out a program though I'm not trained in this
language. I thought I'll ask this qn cos I needed info on this as well
:)



Relevant Pages

  • Re: brain teasers
    ... warnings as an exercise for the reader:) ... I suspect it is historic. ...
    (comp.lang.c)
  • Re: [9fans] handling notes
    ... Or insert a sleepafter the write in cat. ... Why either of those would fix the problem is ... an exercise to the reader. ...
    (comp.os.plan9)
  • Re: egrep match nine digit
    ... It should be pretty easy to see and fix, ... so that's left as an exercise for the reader. ...
    (comp.unix.shell)
  • Re: brain teasers
    ... warnings as an exercise for the reader:) ... I suspect it is historic. ... Adding them both still does not yield all the warnings that are ...
    (comp.lang.c)
  • Re: Philosophy (Was: religion help)
    ... leave as an exercise for the reader. ... Dude, I started writing software early in 1969, it causes a form of ... brain damnage called "literal sumbitch" as you ought to realize by ...
    (rec.arts.sf.composition)

Loading