DS

Traverse Operation

In traversing operation of an array, each element of an array is accessed exactly for once for processing.
This is also called visiting of an array.

Example

Let LA is a Linear Array (unordered) with N elements.

//Write a Program which perform traversing operation.
#include <stdio.h>
void main()
{
   int LA[] = {2,4,6,8,9};
   int i, n = 5;

   printf("The array elements are:\n");

   for(i = 0; i < n; i++)
   {
      printf("LA[%d] = %d \n", i, LA[i]);
   }
}

Output:

Command Prompt
The array elements are:
LA[0] = 2
LA[1] = 4
LA[2] = 6
LA[3] = 8
LA[4] = 9



Subscribe us on Youtube

Share This Page on


Ask Question