Traversal in One Dimensional Array
The method of processing each element in the array exactly once is known as Traversal.
In array Traversal starts from first element in the array an ends at the last element of the array.
Algorithm for Array Traversal
Step 1: START = 0
Step 2: Repeat Step3 while (START<N)
Step 3: Read A [START]
START = START + 1
Program for Array Traversal
#include<stdio.h>
#include<conio.h>
#define N 5
void main()
{
int a[N]={10,20,30,40,50};
void traverse(int *a);
clrscr();
traverse(a);
getch();
}
void traverse(int *a)
{
int START=0;
while(START<N)
{
printf("%d\n",a[START]);
START=START+1;
}
}