C-Arrays - ECE 175: Introductory C for Engineers Arrays ECE...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ECE 175: Introductory C for Engineers Arrays ECE 175: Introductory C for Engineers - Arrays Basics of arrays Allows identical items to be grouped into a composite data structure Example: Scores of students in this class Declaring and referencing arrays Declaration specifies array name and the number of elements in the array The number of elements must be a constant (may use constants through #define ) The elements are numbered from 0, 1, 2, ..., N-1 Every element of the array may be viewed as an independent variable The usage of individual element is exactly the same for any simple variables that we have seen so far C does not check for array boundaries; so be careful in accessing arrays 2 10 x[0] 5 x[1] 2 x[2]-3 x[3] 25 x[4] 1001 x[5]-1 x[6] 23 x[7] Example: int x[8]; double d[10]; char c[255]; ECE 175: Introductory C for Engineers - Arrays Array initialization Initialization at declaration The numbers declared are sequentially assigned to elements starting from 0 The value of -1 at the end helps in identifying when the array ends Otherwise, count the elements If you do not specify the array limit explicitly, it will be taken based on the initialization set If the array limit explicitly specified is lower, then compiler will provide warnings...
View Full Document

Page1 / 10

C-Arrays - ECE 175: Introductory C for Engineers Arrays ECE...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online