Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Initializing sum to zero wouldn't compile Date: Sun, 30 Aug 2015 16:10:07 -0700 Organization: None to speak of Lines: 30 Message-ID: References: <5f70d0ca-8b6b-4c11-a2d3-10a5fb65c1c3@googlegroups.com> <87egimmabl.fsf@bsb.me.uk> <225f3e7d-c708-40ec-90f6-b91a57560933@googlegroups.com> <87zj19vwvt.fsf@bsb.me.uk> <877focwja7.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="32302"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+dVAFElMSMOZZPodzXpJ7O" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:ux9fdxgduuGHwlzp+GLhwWY4bkE= sha1:1De49dlMoDHP5fObGt5Y5zSOHMM= Xref: csiph.com comp.lang.c:68728 Ben Bacarisse writes: > Keith Thompson writes: >> Ben Bacarisse writes: >>> Alla _ writes: >> [...] >>>> As to arrays, I am using an array because this >>>> exercise is part of the chapter on arrays. >>> >>> Ah. Then I suspect you are doing it wrong. Using an array in a >>> pointless way is unlikely to be what the exercise wants. >> >> I disagree. I think the exercise (to compute the average of three >> floating-point values using an array) has two parts: to read values >> into an array, and to compute the average of the values in an array. >> Both are sensible things to do. The fact that the combination >> is more easily done without using an array would be relevant in a >> real-world program, but not in an introductory exercise. > > It looks like we agree but you say that you disagree so I must have made > my point badly. Assigning to an array element which is then ignored is > "doing it wrong" and "unlikely to be what the exercise wants". What you > describe is what the exercise probably wants. You're right, we agree. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"