C++ Program To Reverse Array Elements Using Function


In this tutorial we will learn to Reverse Array Elements Using Function In C++. Array is a variable which can store multiple element of same data type.Manipulation of array is a very necessary step for any project. In this program we will take input from user, store it in a array then print the reverse array element.

C++ Program To Reverse Array Elements Using Function

C++ Program To Reverse Array Elements Using Function

#include<iostream.h> #include<conio.h> void Reverse_Array(int array[],int size); void main() { int i,a[10],size; clrscr(); cout<<"Enter size of Array ( Max:10 ): "; cin>>size; cout<<"\nEnter any "<<size<<" elements: \n"; for(i=0; i<size; i++) { cin>>a[i]; } cout<<"\nStored Data in Array: \n\n"; for(i=0;i<size;i++) { cout<<" "<<a[i]<<" "; } // Calling Reverse Array Values Function Reverse_Array(a,size); cout<< "\n\nReversed Array Elements are: \n\n"; for(i=0;i<size;i++) { cout<<" "<<a[i]<<" "; } cout<<"\n"; getch(); } //------Reverse Array Function--------------- void Reverse_Array(int array[],int size) { int temp; size--; for (int i=0;size>=i;size--,i++) { temp=array[i]; array[i]=array[size]; array[size]=temp; } }


Enter size of Array ( Max:10 ): 5 Enter any 5 elements 4 7 8 3 9 Stored Data in Array: 4 7 8 3 9 Reversed Array Elements are: 9 3 4 7 8

Struggling to Understand Algorithm and Flowchart? Try our Notes

Want to Test Your Knowledge on Algorithm and Flowchart?


Recommended Deals End in

Online Games
Play 2048 Game Online and Relax.
Play 2048 Game Online

Search Tags

    Reverse array positions in c++

    C++ algorithm for reversing an array

    Pseudocode for reversing an array using c++ program