Access array element value via index - C Array

C examples for Array:Array Element

Description

Access array element value via index

Demo Code

#include <stdio.h>

int main (void)
{
    int values[10];
    int index;//from   w  ww . ja  va  2  s.  com

    values[0] = 1;
    values[2] = -10;
    values[5] = 30;
    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;
}

Result


Related Tutorials