Access array element in a nested for loop - C Array

C examples for Array:Array Element

Description

Access array element in a nested for loop

Demo Code

#include <stdio.h>

int main (void)
{
    int numbers[10] = { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

    for (int j = 0; j < 10; ++j )
        for (int i = 0; i < j; ++i )
            numbers[j] += numbers[i];//from  www  . j  a v a 2  s.co  m

    for (int j = 0; j < 10; ++j )
        printf("%i ", numbers[j]);

    printf("\n");

    return 0;
}

Result


Related Tutorials