Write a program to read n number in an array and display it in reverse order

1. Write a program to read n number in an array and display it in reverse order. 
  1. #include<stdio.h>

  2. void main()
  3. {
  4.     int n;
  5.     int arr[100]; //can be stored upto 100 numbers
  6.     
  7.     printf("Please input the number of elements to store in the array : ");
  8.     scanf("%d", &n);

  9.     printf("Please input %d numbers : ", n);
  10.     for(int i=0; i<n; i++){
  11.         scanf("%d", &arr[i]);
  12.     }

  13.     printf("Reverse the numbers are : ");
  14.     for(int i=n-1; i>=0; --i){  //--i or i-- both are okay
  15.         printf("%5d", arr[i]);
  16.     }
  17. }

একটি মন্তব্য পোস্ট করুন