Help me in Solving this? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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; }

30th Dec 2019, 12:20 PM
Tom
Tom - avatar
1 Answer
+ 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.
30th Dec 2019, 12:33 PM
Avinesh
Avinesh - avatar