Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | jt@toerring.de (Jens Thoms Toerring) |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: programming in c: array; for loop to initialize values |
| Date | 2015-08-20 17:32 +0000 |
| Organization | Freie Universitaet Berlin |
| Message-ID | <d3mh92F3c5nU1@mid.uni-berlin.de> (permalink) |
| References | <43dff05d-eda8-4a4d-b9e5-4de3e9e9f21e@googlegroups.com> |
Alla _ <modelling.data@gmail.com> wrote:
> I am at chapter 6 of Programming in C, and
> here is the task:
> Modify Program 6.1 so that the elements of the
> array are initially set to zero. Use a for loop to perform
> the initialization.
> I don't understan what is being asked. I would be
> grateful for explanation - what exactly shall I do
> with the program 6-1.c; does "elements of the array are
> initially set to zero" mean that each element like
> values[0], etc, should become values [0] = 0, values [2] = 0, etc?
Yes, exactly. All of them are to be set to 0 (instead to
a lot of different values as it's done in the original
program). And for that you're supposed to use a for loop,
like the one used later for prinitng the values
> I hope if I understand this part, I will be able to
> understand how to use for loop for this initialization.
> Here is program 6-1.c
> #include <stdio.h>
> int main (void)
> {
> int values[10];
> int index;
>
> values[0] = 97;
> values[2] = -100;
> values[5] = 350;
> values[3] = values[0] + values[5];
> values[9] = values[5] / 10;
> values[2]--;
>
> for (index = 0; index < 10; index++)
> printf ("values[%i] = %i\n", index, values[index]);
>
> return 0
> }
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
programming in c: array; for loop to initialize values Alla _ <modelling.data@gmail.com> - 2015-08-20 10:22 -0700
Re: programming in c: array; for loop to initialize values "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-08-20 10:29 -0700
Re: programming in c: array; for loop to initialize values Alla _ <modelling.data@gmail.com> - 2015-08-20 11:26 -0700
Re: programming in c: array; for loop to initialize values "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-08-20 11:37 -0700
Re: programming in c: array; for loop to initialize values Barry Schwarz <schwarzb@dqel.com> - 2015-08-20 16:47 -0700
Re: programming in c: array; for loop to initialize values Tim Rentsch <txr@alumni.caltech.edu> - 2015-09-06 13:38 -0700
Re: programming in c: array; for loop to initialize values Barry Schwarz <schwarzb@dqel.com> - 2015-09-07 12:38 -0700
Re: programming in c: array; for loop to initialize values Tim Rentsch <txr@alumni.caltech.edu> - 2015-09-07 23:00 -0700
Re: programming in c: array; for loop to initialize values jt@toerring.de (Jens Thoms Toerring) - 2015-08-20 17:32 +0000
Re: programming in c: array; for loop to initialize values Alla _ <modelling.data@gmail.com> - 2015-08-20 11:27 -0700
Re: programming in c: array; for loop to initialize values Keith Thompson <kst-u@mib.org> - 2015-08-20 12:44 -0700
Re: programming in c: array; for loop to initialize values "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-08-20 13:34 -0700
Re: programming in c: array; for loop to initialize values Alla _ <modelling.data@gmail.com> - 2015-08-21 04:03 -0700
Re: programming in c: array; for loop to initialize values Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-08-21 02:08 -0700
Re: programming in c: array; for loop to initialize values Keith Thompson <kst-u@mib.org> - 2015-08-21 10:22 -0700
Re: programming in c: array; for loop to initialize values James Kuyper <jameskuyper@verizon.net> - 2015-08-21 13:17 -0400
Re: programming in c: array; for loop to initialize values Alla _ <modelling.data@gmail.com> - 2015-08-21 04:07 -0700
csiph-web