Upload
annice-obrien
View
212
Download
0
Embed Size (px)
Citation preview
Copyright © 2012 Pearson Education, Inc.Copyright © 2012 Pearson Education, Inc.
9/4/1435 h Sunday
Lecture 1Array’s Terminologies
Copyright © 2012 Pearson Education, Inc.Copyright © 2012 Pearson Education, Inc.
Computer Programming (2)Code & No.: CS 104
CREDIT HOURS: 5 UNITLecture 3.0 hours/weekLab: 2.0 hour/on every week
a. This course introduces the students to the concept of object oriented programming language
b. Also deals with instructors, destructors and, functions & operators overloading
c. The course also looks into Arrays in details as one of the applications ..
Copyright © 2012 Pearson Education, Inc.Copyright © 2012 Pearson Education, Inc.
Learning Objectives:
• Identify the role of programming in our life by learning the principals and Concepts of OOP,
• Demonstrate understanding of objects, classes • Learning the benefits of some special functions like
constructors & destructors• References:
Starting Out with C++
TONNY GADDIS
Seventh Edition
3
Copyright © 2012 Pearson Education, Inc.Copyright © 2012 Pearson Education, Inc.
Computer Programming (2)Code & No.: CS 104
Pre-requisite: CS 102 Level: 3rd Course Contents
1. Arrays2.Introduction to object oriented programming
language. 3.several C++ enhancements to C.4. what classes, objects, member functions and
data members are.5.how destructors are used to perform
termination.
Copyright © 2012 Pearson Education, Inc.Copyright © 2012 Pearson Education, Inc.
.5.housekeeping on an object before it is destroyed .
6.what operator overloading is and how it makes programs more readable and programming more convenient.
7.To create classes by inheriting from existing classes and how inheritance promotes software reuse, the use of inheritance to customize existing software.
Copyright © 2012 Pearson Education, Inc.Copyright © 2012 Pearson Education, Inc.
.8. what polymorphism, how it makes
programming more convenient and how it makes systems more extensible and maintainable .
9. The formatted input/output and file processing
10. Some applications (Arrays, Queues, Linked Lists, and sorting algorithms.
Text books: C ++ How to progrm H. M. Deitel, P. J. Deitel, 1998: Prentice Hall.
Copyright © 2012 Pearson Education, Inc.Copyright © 2012 Pearson Education, Inc.
Arrays
Copyright © 2012 Pearson Education, Inc.Copyright © 2012 Pearson Education, Inc.
Q: Define an array?An array is a variable that can store
multiple values of the same typeQ: Write a format for declaring a one
dimensional array?
EX: int tests[5];
<Data type> < Array Name > [ Array Size declarator] ;
Copyright © 2012 Pearson Education, Inc.Copyright © 2012 Pearson Education, Inc.
Q: Design an array - Memory Layout for the following array
int tests[5];allocates the following memory:
Subscripts 0 1 2 3 4
first element
second element
third element
fourth element
fifth element
Copyright © 2012 Pearson Education, Inc.Copyright © 2012 Pearson Education, Inc.
Array Terminologies Q: What is the difference between
the array size declarator and the array size ?
The array size declarator shows the number of elements in the array.
The size of an array is the total number of bytes allocated for it . It is =
(number of elements) * (number of bytes for each element)
Copyright © 2012 Pearson Education, Inc.Copyright © 2012 Pearson Education, Inc.
.Q: Calculate the size of these
arrays? 1. int tests[5] is an array of 20 bytes, assuming
4 bytes for an int
2. long double measures[10]
is an array of 80 bytes, assuming 8 bytes for a long double