Program to Traverse an Array.

Traverse: Traverse means to view or display or by define it “Transverse means to move or travel through an area.”

 

Let’s open turbo c/c++ and write the following Code:

 

Code:

 

 

#include<stdio.h>

#include<conio.h>

void traverse();

long int n,a[100];

void main()

{

long int i;

clrscr();

printf(“enter range of array:\n”);

scanf(“%li”,&n);

printf(“enter all elements of array:”);

for(i=0;i<n;i++)

{

scanf(“%li”,&a[i]);

}

traverse() ;

getch();

}

void traverse()

{

long int i;

for(i=0;i<n;i++)

{

printf(“elements you have entered are :\n “,a[i]);

}

}

 

 

Output:

 

 

output

 

Happy Coding.

 

 

 

 

Tags: ,

Comments are closed.