Upcoming SlideShare
×

Numeric Arrays [6]

943
-1

Published on

Published in: Technology, Business
0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
Your message goes here
• Be the first to comment

• Be the first to like this

Views
Total Views
943
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
11
0
Likes
0
Embeds 0
No embeds

No notes for slide

Numeric Arrays [6]

1. 1. Programming & Algorithm Numeric Arrays August 07, 2006
2. 2. What is an Array? <ul><li>An array is a collection of data storage, each having the same data type and the same name. </li></ul><ul><li>Each Storage location in an array is called an array element . </li></ul>
3. 3. What is an Array? <ul><li>A single-dimensional array is an array that has only a single subscript/index. </li></ul><ul><li>A multi-dimensional array is an array that has more than one subscript/index. </li></ul>
4. 4. Naming and Declaring Arrays <ul><li>The rules for assigning names to arrays are the same as for variable names. </li></ul><ul><li>A single-dimensional array declaration has the following form: </li></ul><ul><li>array_name : array [ size ] of typename </li></ul><ul><li>A multi-dimensional array declaration has the following form: </li></ul><ul><li>array_name : array [ size ] … [ size ] of typename </li></ul>
5. 5. Exercises <ul><li>Create an algorithm that continually inputs an integer (1~1000) and stop asking when the input is minus one. The algorithm displays all numbers that’s inputted more than one times on screen. The largest number is displayed first. </li></ul><ul><li>E.g.: </li></ul>Number 5 is shown 3 times. Number 1 is shown 2 times. 1 4 5 1 5 5 6 -1 Output Input
6. 6. Exercises <ul><li>There are two group of ascending sorted numbers. Each group has 10 numbers of integer. Create an algorithm that asks numbers for those groups, unites them in the 3 rd group, sorts the 3 rd group in ascending order, and display the 3 rd group on screen. </li></ul><ul><li>E.g.: </li></ul>1 2 3 3 4 5 5 7 8 11 12 15 16 20 21 23 25 30 31 33 3 rd group 2 3 3 15 16 21 23 30 31 33 2 nd group 1 4 5 5 7 8 11 12 20 25 1 st group