- Home
- Course Category
- Course Result
- Course Detail
Hot Line: 0124-2383121
Course Introduction
Programs for practice
In the program below, we've introduced beginers to programming in C++
Source Code: Reverse Array
class="program_box">/* C++ Program - Reverse Array */ #include<iostream.h> #include<conio.h> void main() { clrscr(); int arr[50], size, i, j, temp; cout<<"Enter array size : "; cin>>size; cout<<"Enter array elements : "; for(i=0; i<size; i++) { cin>>arr[i]; } j=i-1; // now j will point to the last element i=0; // and i will be point to the first element while(i<j) { temp=arr[i]; arr[i]=arr[j]; arr[j]=temp; i++; j--; } cout<<"Now the Reverse of the Array is : \n"; for(i=0; i<size; i++) { cout<<arr[i]<<" "; } getch(); }Output
Enter array size: 10 Enter array elements: 1 2 4 5 7 3 8 9 1 5 Now the Reverse of the Array is: 5 1 9 8 3 7 5 4 2 1