-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrayrev.c
More file actions
34 lines (32 loc) · 786 Bytes
/
Copy patharrayrev.c
File metadata and controls
34 lines (32 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//Prabhjit Singh
//pj92singh
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>
/* this program takes an int size n
for an array then allocates an array of that size
and takes in input from user to fill it up
then prints out the array from the last spot to
the first spot (reverse)
*/
int main(){
int n, i, j;
//scan size of array
scanf("%d",&n);
//allocate an array of that size
int *arr = malloc(sizeof(int) * n);
printf("%d\n", n);
//put the numbers in the array
for(j=0; j<n; j++){
scanf("%d", arr[j]);
}
//print out the array in reverse
for(i=(n-1); i >= 0; i--){
printf("%d ", arr[i]);
}
return 0;
}