OK I have this next program which asks exactly this:
Use the expression sizeof(a) / sizeof(a[0]) (or a macro with this value) for the array length.
I came up w/ this code, however my logic tells me I am not using it correctly. Because whatever number I put in for N is the array size. It compiles fine though.Any advice?
CJ
Code:#include <stdio.h> #define N 10 #define SIZE (sizeof(a) / sizeof(a[0])) main () { int a[N], i = 0; printf("Enter numbers: "); for (i = 0; i < SIZE; i++) scanf("%d", &a[i]); printf("In reverse order:"); for (i = SIZE - 1; i >= 0; i--) printf(" %d", a[i]); printf("\n"); return 0; }



LinkBack URL
About LinkBacks
Any advice?


