COLLEGE OF COMPUTER STUDIES
CCS003L
(COMPUTER PROGRAMMING 1)
EXERCISE
6
ARRAYS
I. <
II.
III.
score
Name of Student Name of Professor
Date Performed Date Submitted
OBJECTIVES
At the end of this exercise, students must be able to:
Define what is an array
Know how declare, initialize, and use and single and multi-dimensional arrays.
IV. BACKGROUND INFORMATION
An array is a sequential collection of data storage locations, each of which holds the same
type of data. Each storage location is called an element of the array.
You declare an array by writing the type, followed by the array name and the subscript.
The subscript is the number of elements in the array, surrounded by square brackets. For
example:
long LongArray[25];
declares an array of 25 long integers, named LongArray.
V. LABORATORY ACTIVITY
ACTIVITY 6.1: Sorting Arrays
Write a program that will ask the user to enter the size of the array n < 100. Once the
array size is validated, it is required that the user will enter the elements of the array.
Finally, display the sorted array elements using any sorting algorithm.
Sample run:
Enter the size of the array: 4
Array element 1: 6
Array element 2: 4
Array element 3: 5
Array element 4: 2
The sorted array is: 2 4 5 6
ACTIVITY 6.2: Multiplication table
Create a program that will accept two integer numbers. These integer numbers will be the
limit of the multiplication table. Store the values in a two-dimensional array.
Sample output:
Enter x: 2
Enter y: 3
1 2 3
2 4 6
VI. QUESTION AND ANSWER
1. Why is it necessary, being a programmer, to use arrays?. What are the risks of not
using arrays?
2. When do single dimensional array is usually used?
V. ASSESSMENT
Department Information Technology
Subject Code ITPROG1
Description INTRODUCTION TO PROGRAMMING
Term/Academic Year
Note: The following rubrics/metrics will be used to grade students’ output in the lab
Exercise 6.
Program (100 pts.) (Excellent) (Good) (Fair) (Poor)
Program Program executes Program executes Program executes Program does not
execution (20pts) correctly with no with less than 3 with more than 3 execute (10-11pts)
syntax or runtime errors (15-17pts) errors (12-14pts)
errors (18-20pts)
Correct output Program displays Output has minor Output has multiple Output is incorrect
(20pts) correct output with errors (15-17pts) errors (12-14pts) (10-11pts)
no errors (18-20pts)
Design of output Program displays Program displays Program does not Output is poorly
(10pts) more than expected minimally expected display the required designed (5pts)
(10pts) output (8-9pts) output (6-7pts)
Design of logic Program is logically Program has slight Program has Program is incorrect
(20pts) well designed (18- logic errors that do significant logic (10-11pts)
20pts) no significantly errors (3-5pts)
affect the results (15-
17pts)
Standards Program code is Few inappropriate Several inappropriate Program is poorly
(20pts) stylistically well design choices (i.e. design choices (i.e. written (10-11pts)
designed (18-20pts) poor variable names, poor variable names,
improper improper
indentation) (15- indentation) (12-
17pts) 14pts)
Delivery The program was The program was The program was The program was
(10pts) delivered on time. delivered a day after delivered two days delivered more than
(10pts) the deadline. (8- after the deadline. (6-two days after the
9pts) 7pts) deadline. (5pts)
Topic ARRAYS
Lab Activity No 6.1
Lab Activity Sorting Arrays
CLO 2, 3
Program execution (20)
Correct output (20)
Design of output (10)
Design of logic (20)
Standards (20)
Delivery (10)
TOTAL
Topic ARRAYS
Lab Activity No 6.2
Lab Activity Multiplication table
CLO 2, 3
Program execution (20)
Correct output (20)
Design of output (10)
Design of logic (20)
Standards (20)
Delivery (10)
TOTAL