Create One-Dimensional Arrays and initialize it - C Array

C examples for Array:Array Element

Introduction

Here is how to initialize an array.

int iArray[5] = {0, 1, 2, 3, 4}; 

Another way to initialize your array elements is to use looping structures such as the for loop.

Demo Code

#include <stdio.h> 
int main() // w  w w  . ja  v a 2s  . c om
{ 
   int x; 
   int iArray[5]; 
   for ( x = 0; x < 5; x++ ) 
      iArray[x] = 0; 
      
   printf("Arrays initialized");
}

Result


Related Tutorials