Answers for "how to reverse the elements of an array"

7

reverse array javascript

var rev = arr.reverse();
Posted by: Guest on April-01-2020
0

reverse array

#include<iostream>
using namespace std;
int main()
{
    int arr[100], tot, i, j, temp;
    cout<<"Enter the Size for Array: ";
    cin>>tot;
    cout<<"Enter "<<tot<<" Array Elements: ";
    for(i=0; i<tot; i++)
        cin>>arr[i];
    cout<<"nThe Original Array is:n";
    for(i=0; i<tot; i++)
        cout<<arr[i]<<" ";
    j = tot-1;
    for(i=0; i<j; i++, j--)
    {
        temp = arr[i];
        arr[i] = arr[j];
        arr[j] = temp;
    }
    cout<<"nnThe Reverse of Given Array is:n";
    for(i=0; i<tot; i++)
        cout<<arr[i]<<" ";
    cout<<endl;
    return 0;
}
Posted by: Guest on October-11-2021

Code answers related to "how to reverse the elements of an array"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language