Skip to content

Instantly share code, notes, and snippets.

@GurjotSinghMahi
Created January 24, 2015 06:41
Show Gist options
  • Save GurjotSinghMahi/d194a1b70c8326984538 to your computer and use it in GitHub Desktop.
Save GurjotSinghMahi/d194a1b70c8326984538 to your computer and use it in GitHub Desktop.
C++ demonstration of Array Traversing Algorithm
#include<iostream>
using namespace std;
int main()
{
int arr[20],range,n;
cout<<"enter the range of elements"<<endl;
cin>>range; //input the range of items to be inserted
cout<<"enter the array"<<endl;
for(n=0;n<range;n++)
cin>>arr[n]; //input the item in array
for(int c=0;c<range;c++) //performs traversing
cout<<"you have entered "<<arr[c]<<" at "<<c+1<<" position"<<endl; //output the result
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment