+ 1
Help me in Solving this?
#include <stdio.h> int main() { int n, sum=0; scanf("%d",&n); int a[n]; for(int i=0; i<n; i++) scanf("%d",&a[i]); printf("\n%d",a); //What does this line output? It ha scompiled successfully int* b=&a; printf("\n%p",b); for(int i=0; i<n; i++){ sum=sum+a[i]; } printf("\nSum=%d",sum); return 0; }
1 Odpowiedź
+ 1
"a" is a pointer type so probably it will compile since pointers are of type - unsigned long int.
But you should use the format specifier "%lu" to escape errors, if at all they occur.
Edit: It should output the address of the array. "a" always points to the address of first element in the array.