Answers 851
F
- The following is one of many possible answers:
#include <stdio.h>
/ Declare a single-dimensional array /
int elements[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
int new_array[10];
int idx;
int main( void )
{
for (idx = 0; idx < 10; idx++)
{
new_array[idx] = elements[idx] + 10 ;
}
for (idx = 0; idx < 10; idx++)
{
printf( “\nelements[%d] = %d \tnew_array[%d] = %d”,
idx, elements[idx], idx, new_array[idx] );
}
return 0;
}
Answers for Day 9
Quiz
- The address-of operator is the &sign.
- The indirection operator is used. When you precede the name of a pointer by ,it
refers to the variable pointed to. - A pointer is a variable that contains the address of another variable.
- Indirection is the act of accessing the contents of a variable by using a pointer to
the variable. - They are stored in sequential memory locations, with lower array elements at lower
addresses.
6.&data[0]
data - One way is to pass the length of the array as a parameter to the function. The sec-
ond way is to have a special value in the array, such as NULL, signify the array’s
end. - Assignment, indirection, address-of, incrementing, differencing, and comparison.
49 448201x-APP F 8/13/02 11:22 AM Page 851