CS Behind the Curtain (CS195 2003S)
Primary:
[Front Door]
[Current]
[Glance]
-
[Blurb]
[Disabilities]
[Honesty]
[Instructions]
[Links]
[Search]
[Syllabus]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Readings]
[Reference]
ECA:
[About]
[Grades]
[Quizzes]
[Submit Work]
[Change Password]
[Reset Password]
Misc:
[Walker/Fall 2001]
[SamR]
Summary: In today's laboratory, we explore different issues pertaining to arrays.
Contents:
Here is a sample initialization of a one-dimensional array of integers.
int ant[5] = { 5, 2, 7, 3, 4 };
Figure out how to initialize the two-dimensional array bat
so that the first row contains 8, 16, and 32 and the second row contains
5, 7, and 9.
int bat[2][3] = figure-this-out;
Suppose we've declared bat
as above and cow
and i
as follows:
int *cow; int i;
a. What do you expect the effect of the following code to be?
cow = (int *) bat; for (i = 0; i < 6; i++) { printf("cow[%d]: %d\n", i, cow[i]); } /* for */
b. Verify your results experimentally.
Consider the following declaration of a three-dimensional array:
int chinchilla[2][3][4];
a. How many elements does chinchilla
have?
b. Can one initialize chincilla
while declaring it?
c. Where in memory is chinchilla[i][j][k]
?
d. How would you verify your previous answer?
Implement iterative binary search of an array of integers in C.
Implement quicksort of an array of integers in C.
Primary:
[Front Door]
[Current]
[Glance]
-
[Blurb]
[Disabilities]
[Honesty]
[Instructions]
[Links]
[Search]
[Syllabus]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Readings]
[Reference]
ECA:
[About]
[Grades]
[Quizzes]
[Submit Work]
[Change Password]
[Reset Password]
Misc:
[Walker/Fall 2001]
[SamR]
Disclaimer:
I usually create these pages on the fly
, which means that I rarely
proofread them and they may contain bad grammar and incorrect details.
It also means that I tend to update them regularly (see the history for
more details). Feel free to contact me with any suggestions for changes.
This document was generated by
Siteweaver on Fri May 2 14:19:41 2003.
The source to the document was last modified on Mon Feb 17 13:54:16 2003.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS195/2003S/Labs/arrays.html
.
You may wish to
validate this document's HTML
;
;
Check with Bobby