C By Discovery (4th Edition)

Info iconThis preview shows pages 1–2. 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 Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 Intermediate Programming CSE 1320 Lecture 05 Chapter 4: 4.1-4.4 One Dimensional Arrays • Aggregate type that stores multiple data values with the same type • Sets, collections, and sequences of related data in any dimension • Access all element in the array test_scores 89 75 93 68 77 83 78 65 92 73 0 1 2 3 4 5 6 7 8 9 variable name data values indices cell Array Declaration type of elements name of array brackets with (possibly) number of cel s int test_scores[10]; • Contiguous block of memory Initialization of Arrays • Need to be initialized before use • Initialize with assignment statements – Executable code in a loop – Array declaration #include <stdio.h> int main(void) { int test_scores[10]; int i; for (i=0; i<10; i++) { scanf(“%d”, &test_scores[i]): } return 0; } Initialization of Arrays char name[7] = {‘G’, ‘u’, ‘e’, ‘r’, ‘r’, ‘a’, ‘\0’}; int numbers[7] = {1, 3, 2, 0}; float dollars = {1.37, 45.68, 3.45}; name G u e r r a \0 0 1...
View Full Document

{[ snackBarMessage ]}

Page1 / 3

Lecture05 - 1 Intermediate Programming CSE 1320 Lecture 05...

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

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