Algorithm For Traversing an Array With Program

Errorlogger
0

Traversing (LA, UB, LB)

In this we have array LA specify the Linear Array, UB specify the Upper Bound, LB specify the Lower Bound.

Algorithm for Traversing an Array

  1. Set K: = LB
  2. Repeat steps 3 and 4 While K < UB
  3. Apply process LA[K]
  4. Set K: = K + 1 (End of step 2 Loop)
  5. Exit

Write a program to perform traversing operation from the array.

#include <stdio.h>
void main()
{
      int a[10], i, n;
      printf("Enter the range of the array = ");
      scanf("%d", &n);
      printf("Enter array's element's = ");
      for(i = 0; i < n; i ++)
      {
             scanf("%d", &a[i]);
      }
      printf("Array's element's = ");
      for(i = 0; i < n; i ++)
      {
             scanf("%d\t", a[i]);
      }
}

Traversing:- It is the process in which we access the each element of the array exactly once. For this purpose will be initialization the K with the value of LB. LB specify the index number of arrays first element. After that we will apply the operation on the arrays first element. Then we increase the index number of array with once. So that it points to the array next element. This process count in until all the element of array are not process.   

Post a Comment

0Comments

Post a Comment (0)

#buttons=(Accept !) #days=(30)

Our website uses cookies to enhance your experience. Check Now
Accept !