Illustrates two types of array-initialization techniques. - C Statement

C examples for Statement:for

Description

Illustrates two types of array-initialization techniques.

Demo Code

#include <stdio.h>

int main (void)
{
    int array_values[10] = { 0, 1, 2, 3, 4 };

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

    for (int i = 5; i < 10; ++i)
        array_values[i] = i * i;// w ww  .j a  v  a 2 s.  c o m

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

    return 0;
}

Result


Related Tutorials