fork download
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. float a[100], b[100];
  6. int c,d,n;
  7. printf("Enter the number of elements in array\n");
  8. scanf("%d", &n);
  9.  
  10. printf("Enter the array elements\n");
  11.  
  12. for (c = 0; c < n ; c++)
  13. scanf("%f", &a[c]);
  14.  
  15. /*
  16.   * Copying elements into array b starting from end of array a
  17.   */
  18.  
  19. for (c = n - 1, d = 0; c >= 0; c--, d++)
  20. b[d] = a[c];
  21.  
  22. /*
  23.   * Copying reversed array into original.
  24.   * Here we are modifying original array, this is optional.
  25.   */
  26.  
  27. for (c = 0; c < n; c++)
  28. a[c] = b[c];
  29.  
  30. printf("Reverse array is\n");
  31.  
  32. for (c = 0; c < n; c++)
  33. printf("%g\n", a[c]);
  34.  
  35. return 0;
  36. }
Success #stdin #stdout 0s 1836KB
stdin
Standard input is empty
stdout
Enter the number of elements in array
Enter the array elements
Reverse array is