Wednesday, August 31, 2011

How to traverse the array using C++.


//How to traverse the array using C++.
#include<iostream.h>
#include<conio.h>
void main()
{
 int i, k, data[50], n, lb, ub;
 clrscr();
 cout<<endl<<"Enter the number of elements in the array:";
 cin>>n;
 cout<<endl<<"Enter the value of "<<n<<" elements:";
 for(i=0; i<n; i++)
 {
   cin>>data[i];
 }
 lb=0;
 ub=n-1;
 for(k=lb; k<=ub; k++)
 {
  cout<<endl<<k<<" element is "<<data[k];
 }
 getch();
}

Previous Next Home
0 Comments
Comments

Leave a Comment

:)) ;)) ;;) :D ;) :p :(( :) :( :X =(( :-o :-/ :-* :| 8-} :)] ~x( :-t b-( :-L x( =))

Twitter Delicious Facebook Favorites More