Traversing or Outputting an Array in C Language with Free Notes

Introduction

As data can be entered into an Array by using loop statement, data can also be traversed by using loop statements.

To traverse each element of an array, we use a variable in the subscript part in place of constant (for single element).

Example: One Dimensional Array

e.g. //Demonstration of Outputting one Dimensional Array

printf("\n Elements of an array are\n');
for (i = 0; i<9; i++)
    printf("%d \t", S [i];
Free Hand-Written Notes

Example: Two Dimensional Array

//Demonstration of Outputting Two Dimensions array

prinf ("\n Elements of an Array are\n"0;
  for (i=o; i<=4; i++)
{
   for (j=0; j<=5; j++)
        print("%d\t", a [i][j]);
      pritntf("\n");
     }

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top