Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: nested while loop computing triangular number - issues |
| Date | 2015-07-11 12:24 -0400 |
| Organization | Self |
| Message-ID | <55A14351.6000405@verizon.net> (permalink) |
| References | <8e9f29f8-a7d0-42c4-a146-2a0d0b937051@googlegroups.com> <87si8uu5tr.fsf@bsb.me.uk> <ad9fec5e-57e1-46cf-8a35-79ac4434171e@googlegroups.com> |
On 07/11/2015 11:01 AM, Alla _ wrote:
> On Saturday, July 11, 2015 at 6:28:24 PM UTC+4, Ben Bacarisse wrote:
>> Alla _ <modelling.data@gmail.com> writes:
...
>>> int main (void)
>>> {
>>> int n, number, triangular_number, counter;
>>> n = 1;
>>> counter = 1;
>>> triangular_number = 0;
>>
>> Why not
>>
>> int n = 1, triangular_number = 0, counter = 1, number;
>>
>> or
>>
>> int n = 1;
>> int triangular_number = 0;
>> int counter = 1;
>> int number;
>>
>> ?
...
> Do I understand correctly that I have made a mistake here by declaring
> n, triangular_number, counter and number as int, and then have initialized
> all but "number"? I thought that this is a legitimate option in C.
No, it's not a mistake. It is perfectly legitimate. He's asking why you
didn't take advantage of one of the conveniences of C. The following code:
int n;
n = 1;
Has exactly the same effect as
int n = 1;
The second form is just a convenience feature - not using it isn't a
mistake, it just means that you typed more code than you needed to. But
you did type more code than you needed to, and that's what he was asking
about.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
nested while loop computing triangular number - issues Alla _ <modelling.data@gmail.com> - 2015-07-11 06:31 -0700
Re: nested while loop computing triangular number - issues Alla _ <modelling.data@gmail.com> - 2015-07-11 06:52 -0700
Re: nested while loop computing triangular number - issues Siri Cruz <chine.bleu@yahoo.com> - 2015-07-11 07:07 -0700
Re: nested while loop computing triangular number - issues Alla _ <modelling.data@gmail.com> - 2015-07-11 07:27 -0700
Re: nested while loop computing triangular number - issues Siri Cruz <chine.bleu@yahoo.com> - 2015-07-11 08:19 -0700
Re: nested while loop computing triangular number - issues Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-07-11 15:28 +0100
Re: nested while loop computing triangular number - issues Alla _ <modelling.data@gmail.com> - 2015-07-11 08:01 -0700
Re: nested while loop computing triangular number - issues James Kuyper <jameskuyper@verizon.net> - 2015-07-11 12:24 -0400
Re: nested while loop computing triangular number - issues Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-07-11 21:24 +0100
Re: nested while loop computing triangular number - issues Alla _ <modelling.data@gmail.com> - 2015-07-12 09:35 -0700
Re: nested while loop computing triangular number - issues Keith Thompson <kst-u@mib.org> - 2015-07-12 11:55 -0700
Re: nested while loop computing triangular number - issues Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-07-12 22:14 +0100
Re: nested while loop computing triangular number - issues Alla _ <modelling.data@gmail.com> - 2015-07-13 08:05 -0700
Re: nested while loop computing triangular number - issues David Kleinecke <dkleinecke@gmail.com> - 2015-07-11 10:51 -0700
Re: nested while loop computing triangular number - issues Keith Thompson <kst-u@mib.org> - 2015-07-11 14:56 -0700
Re: nested while loop computing triangular number - issues David Kleinecke <dkleinecke@gmail.com> - 2015-07-12 09:32 -0700
Re: nested while loop computing triangular number - issues James Kuyper <jameskuyper@verizon.net> - 2015-07-12 13:19 -0400
Re: nested while loop computing triangular number - issues David Kleinecke <dkleinecke@gmail.com> - 2015-07-13 10:16 -0700
Re: nested while loop computing triangular number - issues Keith Thompson <kst-u@mib.org> - 2015-07-12 11:48 -0700
Re: nested while loop computing triangular number - issues James Kuyper <jameskuyper@verizon.net> - 2015-07-12 15:23 -0400
Re: nested while loop computing triangular number - issues Tim Rentsch <txr@alumni.caltech.edu> - 2015-07-15 11:02 -0700
Re: nested while loop computing triangular number - issues Keith Thompson <kst-u@mib.org> - 2015-07-15 13:19 -0700
Re: nested while loop computing triangular number - issues Tim Rentsch <txr@alumni.caltech.edu> - 2015-07-20 11:01 -0700
Re: nested while loop computing triangular number - issues Alla _ <modelling.data@gmail.com> - 2015-07-11 08:45 -0700
csiph-web