Arrays Introduction

Sort by

recency

|

1330 Discussions

|

  • + 0 comments

    simple code

    int main() {

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

    }

  • + 0 comments

    string reverse

    int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */

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

    }

  • + 0 comments

    include

    include

    include

    include

    include

    using namespace std;

    int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */
    int size; cin>>size; int arr[size]; for(int i=0;i>arr[i]; } for(int i=size-1;i>=0;i--){ cout<

  • + 0 comments

    include

    using namespace std; int main(){ int n; cin>>n; int arr[n]; for (int i=0;i>a; arr[i]=a; } for (int j=n-1;j>=0;j--){ cout<

  • + 0 comments

    Easy and Understable Code:

    int main() {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT */
        int n;
        cin>>n;
        int arr[n];
        for (int i=0; i<n; i++) {
            cin>>arr[i];
        }
        for(int i=n-1; i>=0; i--){
            cout<<arr[i]<<" ";
        }
        return 0;
    }