



















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
A chapter from the ise105: computing fundamentals course on docsity.com. It introduces the concept of arrays as a data structure for storing and organizing related data efficiently. The basics of arrays, including their definition, indexing, and examples of their usage. It also includes exercises for practice.
Typology: Slides
1 / 27
This page cannot be seen from the preview
Don't miss anything!
.
.
Outline 6.1 Introduction 6.2 Arrays 6.3 Declaring Arrays 6.4 Examples Using Arrays
.
6.1 Introduction
Data Structures : “In computer science, a data structure is a particular way of storing and organizing data in a computer so that it can be used efficiently” (NIST)
.
Arrays
.
6.2 Arrays
Namethat ofall array elements (Note of this array have the same name, c)
Positionthe element number within of array c
c[6]
0 62
1 6453 78
c[0] c[1] c[2] c[3]
c[11]
c[10]
c[9]
c[8]
c[7]
c[5]
c[4]
.
6.3 Defining Arrays
.
Array indexing
.
Array indexing
int age[10]; Accessing 5 th^ element of the array c=age[3+2]; OR i=2; c=age[i+3];
.
Example1: Using Arrays
.
Example 2
int totalAge = 0 ; int age[10]; for ( i = 0 ; i < 10 ; i ++ ) { totalAge + = age [ i ] ; }
Outline
.
16
Program Output
Element 0 Value 0 (^12 ) (^34 ) (^56 ) (^78 ) 9 0
.
Copying Arrays
.
Example: 4
.
Example 5
Search a number z in an array
for ( i =0 ; i < 100 ; i ++ ) { if ( z == a [ i ] ) { found = 1 ; break ; } } if ( found == 1 ) printf( “ We found the integer at position %d” ,i) ; else printf( “ The number was not found” );