Initialize array element with for loop - C Array

C examples for Array:Array Element

Description

Initialize array element with for loop

Demo Code

#include <stdio.h>

int main (void)
{
    int values[10];

    for (int index = 0; index < 10; ++index)
        values[index] = 0;/*from  ww w  .j  a va2 s .co m*/

    values[0] = 1;
    values[2] = -1;
    values[5] = 3;
    values[3] = values[0] + values[5];
    values[9] = values[5] / 10;
    --values[2];

    for (int index = 0; index < 10; ++index)
        printf ("values[%i] = %i\n", index, values[index]);

    return 0;
}

Result


Related Tutorials