Sams Teach Yourself C in 21 Days

(singke) #1

DAY 8


WEEK 2


Using Numeric Arrays


Arrays are a type of data storage that you often use in C programs. You had a
brief introduction to arrays on Day 6, “Controlling Your Program’s Order of
Execution.” Today you will learn:


  • What an array is

  • The definition of single- and multidimensional numeric arrays

  • How to declare and initialize arrays


What Is an Array? ..............................................................................................


Anarrayis a collection of data storage locations, each storing the
same type of data and having the same name. Each storage location in
an array is called an array element. Why do you need arrays in your programs?
This question can be answered with an example.
If you’re keeping track of your business expenses for 2003 and filing your
receipts by month, you could have a separate folder for each month’s receipts,
but it would be more convenient to have a single folder with 12 compartments.

NEWTERM

14 448201x-CH08 8/13/02 11:21 AM Page 175

Free download pdf