C++ Program to reverse a single dimensional array using another array [DEVCPP/GCC]

PROGRAM

//Program to reverse a single dimensional array using another array.

# include <iostream>

using namespace std;

int main()
{
int a[5],b[5],i,sum=0;

cout<<"INPUT THE ARRAY ELEMENTS:\n";
for(i=0;i<5;i++)
{
cout<<"a["<<i<<"]=";
cin>>a[i];
}

cout<<"\nREVERSED ARRAY:\n";
for(i=0;i<5;i++)
{
b[i]=a[4-i];
cout<<"b["<<i<<"]="<<b[i]<<endl;
}
 
            return 0;
}

OUTPUT

C++ Program to reverse a single dimensional array using another array with output

Share this

Related Posts

FIND US ON FACEBOOK!