Sunday, August 19, 2018

REV ARRAY

  • Problem Description

    program using pointers to read in an array of integers and print its elements in reverse order
  • CODING ARENA::
  • #include <stdio.h>
    int main()
    {
      int a[100],n,i;
      scanf("%d",&n);
      for(i=0;i<n;i++)
      {
        scanf("%d",&a[i]);
      }
       for(i=n-1;i>=0;i--)
       {
         printf("%d ",a[i]);
       }

    return 0;
    }
  • Test Case 1

    Input (stdin)
    2
    
    1 2
    
    
    Expected Output
    2 1 
  • Test Case 2

    Input (stdin)
    5
    
    1 2 6 8 5
    
    
    Expected Output
    5 8 6 2 1 

No comments:

Post a Comment