CIS3355: Data Structures
The
1.0100 What is the main advantage of an array?
1.0110 What is the main disadvantage of an array?
50.0100 What are the major differences between
automatic, static, and external arrays?
100.0010 Given: char
mystring[30];
If
the base address of mystring is 12453, what would the following command
produce?
Printf(“%lu”,
&mystring[24]);
100.0014 Given: short
shortinteger[100];
If
the base address of shortinteger is 75282, what would the following command
produce?
Printf(“%lu”,
&shortinteger [200]);
100.0016 Given: int
reginteger[50];
If
the base address of reginteger is 16552, what would the following command
produce?
Printf(“%lu”,
®integer [15]);
100.0018 Given: long
longinteger[50];
If
the base address of longinteger is 13454, what would the following command
produce?
Printf(“%lu”,
& longinteger[22]);
100.0020 Given: float
realnumber[50];
If
the base address of realnumber is 21457, what would the following command
produce?
Printf(“%lu”,
&realnumber[34]);
100.0022 Given: double
doublenumber[50];
If
the base address of doublenumber is 15642, what would the following command
produce?
Printf(“%lu”,
& doublenumber[19]);
100.0024 Given: long
double longdoublenumber[50];
If
the base address of longdoublenumber is 43768, what would the following command
produce?
Printf(“%lu”,
& longdoublenumber [187]);
100.0030 Given char
mychar[8][7];
If the base address of the array is 7200, at what address will we find mychar[5][3] ?
100.0032 Given: unsigned
long mydata[4][6];
If the base address of the array is 7200, at what address will we find mydata[3][2] ?
100.0034 Given: float mydata[20][10];
If the base address of the array is 7200, at what address will we find mydata[12][7] ?
100.0036 Given: double
mydata[32][15];
If the base address of the array is 7200, at what address will we find mydata[73][9] ?
100.0090 When I entered the C
code:
long myarray[5];
printf(“%lu”, &myarray[3]);
I received the output: 56884
Looking at RAM, I found:
56868 |
56869 |
56870 |
56871 |
00001100 |
00000001 |
00000000 |
00000001 |
56872 |
56873 |
56874 |
56875 |
00010011 |
00000100 |
00000000 |
00001000 |
56876 |
56877 |
56878 |
56879 |
00000000 |
00001001 |
00000000 |
00000001 |
56880 |
56881 |
56882 |
56883 |
00001001 |
00010000 |
00000001 |
001100010 |
56884 |
56885 |
56886 |
56887 |
00000001 |
11000101 |
11011011 |
111010100 |
56888 |
56889 |
56890 |
56891 |
11111111 |
11111111 |
11111111 |
11101010 |
56892 |
56893 |
56894 |
56895 |
00101101 |
00011001 |
00000010 |
01110001 |
A. What would
be the output of the statement:
printf(“%lu”, &myarray[1]);
?
B. What would be the output of the
statement: printf(“%d”, myarray[4]); ?
C. Explain why
I can enter the command: printf(“%d”, myarray[76]); and still receive output, even though I
declared myarray to only have 5 elements.
100.0100 When I entered the c
code:
int myarray[7], *mypointer;
mypointer = &myarray[3];
printf(“%lu
%lu”,myarray, mypointer);
I received the output: 56871 56889
Looking at RAM, I found:
56868 |
56869 |
56870 |
56871 |
00001100 |
00000001 |
00000000 |
00000001 |
56872 |
56873 |
56874 |
56875 |
00010011 |
00000100 |
00000000 |
00001000 |
56876 |
56877 |
56878 |
56879 |
00000000 |
00001001 |
00000000 |
00000001 |
56880 |
56881 |
56882 |
56883 |
00001001 |
00010000 |
00000001 |
00000000 |
56884 |
56885 |
56886 |
56887 |
11010111 |
00001010 |
01110101 |
11111100 |
56888 |
56889 |
56890 |
56891 |
11010110 |
00000000 |
00000000 |
11011110 |
56892 |
56893 |
56894 |
56895 |
00101101 |
00011001 |
00000010 |
01110001 |
a. What would be the output of the
statement: printf(“%lu”, &myarray[2]); ?
b. What would be the output of the
statement: printf(“%d”, myarray[7]); ?
c. What would be the output of the
statement: printf(“%d”, *mypointer); ?
d. What would be the output of the
statement: printf(“%lu”, --mypointer); ?
e.
Disregarding the previous question, What would be the output of
the statement:
printf(“%d”, *mypointer); AFTER
we issue the statement: ++mypointer; ?