Signup/Sign In

C++ Program To Print Reverse Order And Print Sum Of Its Element Of An Array

Here, we need to write a program to read the 1D array, Display its elements in reverse order and print the sum of the elements or easier way to reverse array c++ or c++ reverse array elements or how to print an array backward in c or print array in reverse order java or print 2n lines in reverse order c++ or print array in reverse order javascript or c++ program for printing 2n lines in reverse sequence or how to print the content of a file in reverse order in c++.

Print Reverse Order And Print Sum Of Its Element Of An Array In C++

You can print array elements from the last index to the zeroth index and add all elements of an array. While you are reversing the array, add all variables of an array and keep the sum in, and at the end of the program print the sum of all variables of an array.

Different methods can be used to reverse the elements of an array like:-

  • Reverse an array using for loop
  • Reverse an array using the reverse() function
  • Reverse an array using the user-defined function
  • Reverse an array using the pointers
  • Reverse an array using the Recursion function
#include<iostream>
using namespace std;
int main()
{
  int a[100],i,n,sum=0;

  cout<<"Enter The Size of Array\n";
  cin>>n;
  
 cout<<"Enter Element Of Array\n";
  for(i=0;i<n;i++)
  {
   cin>>a[i];
  }

  cout<<"Elment in Array is Given Below\n";
  for(i=(n-1);i>=0;i--)
  {
   cout<<a[i]<<"  ";
   sum=sum+a[i];
  }
  cout<<"\n\nSum Of Array Is = "<<sum;
 return 0;

}


Enter The Size of Array
6
Enter Element Of Array
4 8 2 3 69 2
Elment in Array is Given Below
2 69 3 2 8 4

Sum Of Array Is = 88

Conclusion

Here, in this tutorial we have learned how to write a C++ Program To Print Reverse Order And Print the Sum Of Its Element Of An Array.