Initializes an array of 10 elements. Each element should be equal to its subscript. Print each of the 10 elements. - C Array

C examples for Array:Array Element

Description

Initializes an array of 10 elements. Each element should be equal to its subscript. Print each of the 10 elements.

Demo Code

#include <stdio.h>

int elements[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
int idx;/*from  www.j  av  a 2  s.  c  o  m*/

int main( void ){
   for (idx = 0; idx < 10; idx++){
      printf( "\nelements[%d] = %d ", idx, elements[idx] );
   }
   return 0;
}

Result


Related Tutorials