SHARE
TWEET

Untitled

a guest Mar 22nd, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <limits.h>
  4. #include <stdint.h>
  5.  
  6. void reverseArray(int a[], int b[], int length);
  7.  
  8. int main(int argc, const char * argv[]) {
  9.     // Write a program that accepts 10 integers, and displays them in reverse order.
  10.     int a[10], b[10];
  11.     int num;
  12.    
  13.     printf("Enter 10 integers: ");
  14.     for (int i = 0; i < 10; i++)
  15.     {
  16.         scanf("%d", &num);
  17.         a[i] = num;
  18.     }
  19.    
  20.     reverseArray(a, b, 10);
  21.    
  22.     for (int i = 0; i < 10; i++)
  23.     {
  24.         printf("%d ", b[i]);
  25.     }
  26.    
  27.     printf("\n");
  28.    
  29.     return EXIT_SUCCESS;
  30. }
  31.  
  32. void reverseArray(int a[], int b[], int length)
  33. {
  34.     for (int i = 0, j = length - 1; i < length; i++, j--)
  35.     {
  36.         b[j] = a[i];
  37.     }
  38. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top