3/14/2016

Hacker Rank solution for Arrays Introduction In C++

Problem:- Arrays Introduction Hacker Rank Solution or Arrays Introduction hacker rank solution c++ orMulti Level Inheritance in java or Arrays Introduction solution or Arrays Introduction solution in C++ or Arrays Introduction hacker rank solution in Java or Arrays Introduction hacker rank solution c++ or Arrays Introduction hacker rank solution c++ or Arrays Introduction program in c or Arrays Introduction solution in C or Hacker Rank Solution For Arrays Introduction in C++ or Arrays Introduction in C++ or Hacker Rank solution for Arrays Introduction in C++.


Explanation:- We know that array is used to store similar datatype and an array used continues memory location in this problem we have to take an input from user and print reverse output by printing the last index first until an array first index. 

Check- Geeksforgeeks solution for School, Basic, Easy, Medium, Hard Domain.


Submit your solution here:- Click here


Solution:-

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int array[n];

    for(int i = 0; i < n; i++)
   {
        cin >> array[i];
    }

    for(int i = n - 1; i >= 0; i--)
   {
        cin >> array[i];
        cout << array[i] << " ";
    }
    return 0;
}

Output:-


Hacker Rank solution  for Arrays Introduction In C++



Hacker Rank solution  for Arrays Introduction In C++

You May Like This

1. C++ Program To Print All Value Of An Array

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

3. C++ Program To Check Evenness / Oddness Of An Array

4. C++ Program To Check Positive / Negative Number Of An Array

5. C++ Program To Check Primeness Of An Array

6. C++ Program To Sum Of Even-Positive, Even-Negative, Odd-Positive, Odd-Negative Of An Array

7. C++ Program To Check An Array Is Armstrong Or Not

8. C++ Program To Sort An Array Using BUBBLE SORT TECHNIQUE

9. C++ Program To Sort An Array Using SELECTION SORT TECHNIQUE

10.
C++ Program To Merge Two Array In Third Array Unconditionally


4 comments:

  1. for(int i = n - 1; i >= 0; i--){
    // cin >> array[i];
    cout << array[i] << " ";

    I have marked the unnecesarry line. u dont need to read values again cause there isnt a second value entrance.

    ReplyDelete
  2. nt n;
    cin >> n;
    int array[n];

    Hi Execute this piece of code in VS 2013 or any version. Look for the error. Its wrong. Kindly correct it.

    ReplyDelete
    Replies
    1. if you are facing error then change your code:=
      int arr[100],n;
      cin>>n;
      some compiler doesnt support that time of declaration and initilization i advice change you compilor

      Delete