Lesson 9: Arrays
This lesson will show you how to:
- Use string literals
- Assign strings to variables
- One dimensional arrays
Q. What's the difference between a computer and a blonde?
A. You only have to punch information once into a computer.
Arrays are a data structure that is used to store a group
of objects of the same data type in memory. All the elements
of an array must be the same data type, for example float,
char, int, a structure or function. Structures provide a
way to organize related data and will be studied in a later
lesson. Functions provide a way to define a new operation.
They are used to calculate a result or update parameters.
Functions will be covered in a later lesson. T
An array is defined with this syntax.
data type arrayName[size];
Could be used to store the ID numbers of students in a
Could be used to store the daily temperatures in a month
Could be used to store a character string. Character strings
in C are terminated be the null character, '\0'. This
will be discussed later in the this lesson. */
An example program using arrays:
word = ‘H’;
word = ‘e’;
word = ‘l’;
word = ‘l’;
word = ‘o’;
word = 0;
printf(“The contents of word is -? %s\n”,
This program prints the word "Hello" on the
back to top go
to next lesson