HackerRank C++ Arrays Introduction




You'll be given an array of N integers and you have to print the integers in the reverse order.



  1. #include <cmath>
  2. #include <cstdio>
  3. #include <vector>
  4. #include <iostream>
  5. #include <algorithm>
  6. using namespace std;
  7. int main()
  8. {
  9. int n;
  10. cin >> n;
  11. int array[n];
  12. for(int i = 0; i < n; i++)
  13. {
  14. cin >> array[i];
  15. }
  16. for(int i = n - 1; i >= 0; i--)
  17. {
  18. cin >> array[i];
  19. cout << array[i] << " ";
  20. }
  21. return 0;
  22. }




codesadda.com

Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube