Size of array is taken from user..Elements are stored by user..Then reverse of array is displayed..
Select To use this code as it is.. select and copy paste this code into code.cpp file :)
- #include<iostream.h>
- #include<conio.h>
- void main()
- {
- clrscr();
- int ar[10],n,s=0;
- cout<<"Enter size of the array: ";
- cin>>n;
- cout<<"Enter array element: "<<endl;
- for(int i=0;i<n;i++)
- {
- cout<<"Enter element "<<i<<": ";
- cin>>ar[i];
- }
- //Coding by: Snehil Khanor
- //http://WapCPP.blogspot.com
- cout<<"Elements of array in original order: "<<endl;
- for(i=0;i<n;i++)
- cout<<"Element at index number "<<i<<" is: "<<ar[i]<<endl;
- cout<<"Elements of array in reverse order: "<<endl;
- for(i=n-1;i>=0;i--)
- cout<<"Element at index number "<<i<<" is: "<<ar[i]<<endl;
- getch();
- }
2 comments:
this method is hard to understand ....
that why i dont like it ;
Reverse an Array in C++
nice
Post a Comment