+ 2
scanf("%d",&a[i]);
Pls explain this syntax
4 Answers
+ 5
@scott johnson is correct
ampersand (&) is used to reference the address to which you wish to enter the integer.
just a little addition
when using arrays to input some data, there is no need for & before, as an array is an address, and an array at index (arr[2] for example) is simply the the address: starting address + 2*sizeof array datatype
for a single variable however (int x; or something similar), you do need to have & before it when wanting to enter data into it using scanf.
+ 4
%d is for an integer and a[i] is probably an array. So you're reading in input from the keyboard that is expected to be an integer that will be put into the array at index i. As for the ampersand, I'm not entirely sure in this context as I'm more familiar with C++ than C. A single ampersand is usually used for a reference or address.
Edit: Just did a bit of research. What you're saying is: Read this data into this address location.
+ 2
đđ no
0
OK