Download as pdf or txt
Download as pdf or txt
You are on page 1of 91

ITE6102

COMPUTER PROGRAMMING

MODULE1
Hardware, Software, Development?!
A platform is any device on which an application was specially designed to run. A platform can be a
personal computer running Windows. It can also be a personal computer running Linux. Typically, when
we speak of a platform, we usually refer to a specific device running a specific operating system.

Computer

Hardware Development Software

Web Application Operating


Input
Development Development System

Backend
Process API Firmware
Development

Mobile Embedded
Storage Application
Development Systems

Output Data Science Utilities

Figure 1. Components of Computer System

Hardware
We categorize those of computer into input-process-output-storage (IPOS). You need to know about
the categorization to better classify the parts of the computer which you will use in developing an
application. You will use at least one input device, one process device, one output and one storage
device when running your application. This will let the user be immersed in fully experiencing the
capabilities of your application.

Input devices are the parts of the computer which allows the user to provide signals and information to
the processor. This includes the mouse, keyboard, scanners and sensors. The mouse is the part of the
computer which allows the user to easily navigate within an application. The keyboard is the part of the
computer which allows the user to enter textual values in applications. The scanner is the part of the
computer which takes digital copies of any prints, usually texts and images printed on a bond paper.
The sensors are specialized devices attached or embedded in a computer to take different information.
We have fingerprint sensor to take fingerprint samples and optical sensor to take images of our iris,
microphone to take audio samples, and camera to take images.

Biometric sensors are sensors which takes biometric samples like our voices, fingerprints, iris scans and
facial samples. Included in this category are the fingerprint sensors and optical sensors. These are typically
used in information security to protect sensitive information or safeguard objects.
ITE6102
COMPUTER PROGRAMMING

Process devices, processors as we call them, are the of the computers which perform massive
calculations on our entered data through the input devices. They maintain the central functions of the
computer. We are all familiar with the main part of the computer under this category - the central
processing unit or CPU as we call it. The CPU oversees to fully integrate all parts of the computers under
all categories. It is also in charge of carrying out instructions sent by the running applications. Because
of its massive capabilities and functions, this part is called the brain of the computer by which losing this
will render the entire computer useless. Included also in this category is the part of the computer which
processes the graphical outputs - the graphics processing unit or GPU. The GPU enhances the
capabilities of the CPU by rendering graphical information to the output devices.

There is a common misconception with the term central processing unit. What non-computer literate
persons call the CPU is the casing that houses the motherboard and its peripherals including the actual
CPU, or the casing including the peripherals within. However, the actual CPU is the small square chip found
in the center of the motherboard housed by a cooling unit that maintains optimal thermal condition for
the CPU.

Output devices are the parts of the computer which presents intellectual displays to the user, both
digital and in print. The monitor and printer belong in this category. The monitor displays the visual
information processed by the CPU. The GPU is often utilized as well to present displays in the monitor.
The monitor can be installed as part of the computer, like the case in laptops and netbooks, or an
external unit, like the case in Personal Computers and Mac. The printer converts the digital information
from the CPU and renders them on a physical object. The typical printer and 3D printers are some
examples of printers. The main difference between the two is where the information is rendered; in a
typical printer, the information is rendered on a bond paper, whereas in a 3D printer, the information is
rendered as a 3D object.

Storage devices are the parts of the computer which store data and information for later use. These
data and information can be stored permanent or temporary. Included in this category are the hard
drives, flash drives (or pen drives) and the random-access memory (RAM). Hard drives and flash drives
provide permanent storage. Hard drives contain a specialized disk which is utilized as a by-fragment
storage where data and information are stored in a sector of the disk. By-fragment means that the data
and information stored in a hard drive are distributed in separate sectors. A flash drive does not
contain any disk component, but rather has a chip called flash memory. Since there is no physical disk
where the data will be stored or retrieved, flash drives run faster than hard drives. The RAM is the
component found in the motherboard that provides temporary storage for e CPU while the CPU
processes instructions of different applications. Think of the RAM as coin purse where you place coins of
different sizes for future yet immediate use. In this analogy, the coins are used within the day they are
stored.

Software
The computer is not only composed of the hardware parts. Though when we refer to the computer, we
usually refer to its hardware without software counterpart, the computer is just a pile of electrical.
Software are the intangible components of the computer. They make the computer useful since the
software is the reason why the computer does what it does. People usually misunderstand software
and application since they are used interchangeably in daily conversation. However, you will find out
that this is not the case regardless of how true the previous statement is.
ITE6102
COMPUTER PROGRAMMING

The software is just a classification of all the intangible programmed components of the computer. In
this group, we have operating systems, firmware, applications and utilities.

The operating system is environment that have the capability to run firmware, applications and utilities.
These kinds of software have the direct access to the hardware components. Computers usually run only
one operating system. Microsoft Windows, Macintosh, and Linux belong to this category.

It is possible for computers to run more than one operating systems through two methods: Dual Boot
enables a computer to run two different operating system by configuring the master boot sector of the
BIOS; Virtualization enables the user to run multiple operating systems within a parent operating system.

Firmware is a small-sized software that enables the different hardware components of the computer
communicate with each other. Think of these kinds of software as translators. Each hardware has its
own “language” that the operating system does not know how to interpret. Firmware enables the
operating system to recognize the hardware components and assign appropriate resources to fully
utilize the capabilities of the hardware. Drivers can be classified under firmware.

When we talk about software, we usually mean an application. Applications are software that perform
specific tasks for the user. The term application is still a diverse classification of different specialized
software categorized by the general tasks they perform. Included in this classification are the word
processing applications like Microsoft Word and Open Office Writer, spreadsheet applications like
Microsoft Excel and Open Office Spreadsheet, multimedia applications, databases, and office
productivity applications.

Utilities are small-sized application usually kilobytes to some megabytes in file size. These perform
small-time tasks for the user such as taking notes, setting an alarm, connecting to networks and
retrieving specific information about the computer. These kinds of software are directly tied to the
operating system and usually comes as part of the operating system.

Development
Computer Programming is the act of writing codes that the computer can run using a specific
programming language. This may or may not include the compiling or interpreting process.
Characteristically, programming is geared towards a specific task such as calculating the Gaussian
difference of pixels. The end products of programming are source codes and executables. Source codes
are files which contains the codes written in a programming language. They have the file extensions of
their respective programming language.

Executables are the run able versions of the source codes. They are only available to all compiled
programming languages. Windows executables have the file extension of .exe, such as cmd.exe; while
Linux executables typically does not use any file extensions like update-grub.

Programming Language File Extension


Active Server Pages .asp
ASP.NET .aspx
C, Objective-C .c
C++ .cpp
C# .cs
ITE6102
COMPUTER PROGRAMMING

Java .java
PHP .php
Python .py
Ruby .rb
Visual Basic, Visual Basic .NET .vb
Table 1. File Extensions of Common Programming Language Source Codes

Computer Development refers to writing, building and deploying software under a domain. Domains
under Computer Development includes, but is not limited to, Web Development, Desktop Application
Development and Mobile Application Development. Computer Development is accompanied by
Software Development Lifecycle, or commonly referred to as SDLC. SDLC is a set of systematic routine
in maintenance planning of software applications. Computer Development may utilize more than one
programming language and a few frameworks.

The main difference between programming and development is their coverage. Programming normally
involves small-scale applications or modules, whereas development involves medium- to enterprise-
scale applications. Computer Development internally includes programming on the process; hence the
former covers the latter.

Domains of Computer Development

Web Development
Let us start with the most used domain, Web Development. Web Development utilizes the internet,
particularly the World Wide Web. The World Wide Web (WWW) is a subset in the internet where
documents are relating to other documents using hypertext links. These can come in form of file media
files, markup language documents, script files and others.

The most common of which is the Hypertext Markup Language, or HTML. HTML a simple information
system where the user browses for specific topics. They are accompanied by some scripting languages
including JavaScript and VBScripts. They are designed using Cascading Stylesheet, or CSS. However,
HTML are static files which does nothing but present information in form of texts and media.

To create dynamic versions of HTML, we have Front-end Web Development and Back-end Web
Development. Front-end Web Development focuses on using client-side to create interactive and
dynamic user interface. The most common front-end web development scripting language is the
JavaScript through several JavaScript frameworks like ReactJS and AngularJS. Back-end Web
Development focuses on using server-side which run on the hosting server. These provide database
integration and file system management capabilities that cannot run on the user's computer
without compromising security. Some programming languages under back-end development are
ASP.NET, PHP, Ruby on Rails (ROR) and Java Server Pages (JSP).

The advantage of Web Development over other domains is its flexibility. Since majority of the platform
can access the internet, in turn, they can also access the by-product of Web Development. It is platform-
independent hence the "code once, run all" ideal is applicable to this domain.
ITE6102
COMPUTER PROGRAMMING

There exists a hybrid between Front-end Web Development and Back-end Web Development called Full-
Stack Development. This hybrid domain covers both the front-end stack and the back-end stack of Web
Development mastering both the vast client-side script frameworks and diverse sewer-side scripts.

Back-end Development
Back-end Development deals with server configurations. A server is a specialized computer system
that is oriented to serve a lot of services to different client computers. A client computer can be your
personal computer. Those scripts are operating system-specific which instructs the server to perform a
series of interconnected actions such as starting a specific service, or even remotely shutting down
client computers.

Microsoft Windows uses PowerShell for Back-end Development. PowerShell is malleable enough to
run even on a client computer. PowerShell considers the access level of the current user. It also takes
advantage of Active Directory, or AD. AD is a service that provides sewer-controlled directory for
Microsoft Windows domain networks.

Linux uses bash scripts. A bash script is a small script that uses the built-in terminal commands. Linux is
well-known for being programmer-friendly since everything including the kernel is accessible to the
user. A lot of configurations and customizations are available. This makes it flexible for bash scripts to
utilize and even exploit

The advantage of Back-end Development over other domains is direct access to the running operating
system. Though platform-dependent, scripts written for these can-do tasks that is available to the
operating system with the least restriction.

Mobile Development
Mobile Development is the blooming domain of Computer Development. This domain deals with the
growing number of smart devices which includes mobile phones, smart televisions and wears. Per
Statista, a company that conducts enterprise statistical study using open data and enterprise espionage,
there will be about 2.32 billion smartphone users worldwide in 2017, and about 2.87 billion in 2020.
Considering this number of smartphone users alone, the marketability of mobile application is totally
open-entry. Mobile Development is normally platform-dependent meaning your developed mobile
application will only run on a specific range of smart devices.

For Android devices, we have Android Framework using Java as the base programming language. This
includes smartphones, car smart devices, smart TVs running Android-base operating system, and
Android wears. For iOS devices, we have xcode and Objective-C. This includes all variants of iOS devices
including Apple wears.

Though normally platform-dependent, due to the high demand of porting, there have been multi-
platform versions of development environment for mobile development. The big name for this is mono
develop which is a framework that works on all well-known platforms like Microsoft's, Apple's and
Linux's desktop, mobile, and wearable devices. To easily integrate mono develop, in writing codes,
Xamarin is also big name to consider. Xamarin is an integrated development environment (IDE) which
houses mono develop as base framework
ITE6102
COMPUTER PROGRAMMING

Data Science
Going away from the typical development domains, Data Science deals on presenting data in a user-
understandable manner. This includes charts, nodes and maps. This domain aims to present data in
which the user can dynamically change the perspective like from local business perspective to
worldwide coverage. This domain is typically not open source so looking for a place to start on your own
without any enterprise support is virtually difficult.

Under this domain we have Tableau and Salesforce Wave to name some environments.

Application Development
This domain deals with the creation of various applications for desktop and server computers. Though
we are talking about applications for desktop and server computer, we are not limited to local
connectivity between them. We are also talking about the involvement of the internet to provide
various services to other users. Under this domain we have Desktop Application Development, Game
Development and Cloud Application Development.

Desktop Application Development deals with the creation of discrete applications for desktop
computers. This subdomain has a lot of categorization based on their general use like word processing,
spreadsheet and multimedia. Programming languages used in this subdomain varies depending on the
target interface - Graphical User Interface (GUI) and Command-line User Interface (CLI).

GUI Desktop Applications present the users with easy to navigate and manipulate controls for
convenience since they support keyboard and mouse interactions. Programming languages used under
this subdomain include, but are not limited to C++, C# (read as C Sharp) and VB.NET. CLI Desktop
Applications present the user with stream-line experience. Clear majority of CLI Desktop Applications
only support keyboard interactions which gives the users all the flexibility he/she needs to control the
actions of the application continually. Programming languages used under this subdomain include, but is
not limited to, C, C++ (read as C plus plus), C#, VB.NET, Python and Ruby.
ITE6102
COMPUTER PROGRAMMING

Game Development deals with the creation of computer games as means of entertainment and
sometimes education. This subdomain deals heavily with the integration of various scripts to
manipulate objects called models and sprites. Given its extensive coverage, Game Development usually
involves more than one person - the developer, the model artist, the sprites artist and the sound
artist. Programming languages used in this subdomain include, but are not limited to, C++ and C#.

Cloud Application Development deals the hybrid between Web Development and Desktop Application
Development. This subdomain breaks the barrier between the interaction with the web application
and the server and clients running instances of the web application. With a click of a button in the web
application, the server can execute local tasks such as turning on a client computer connected to it,
scheduling shutdown timeout for a running service, and automate various service calls. Programming
languages used in this subdomain include, but is not limited to, JavaScript, PHP, ASP .NET and C#.

The advantage of Application Development over the other domains is the utilization of a computer’s
resources to perform process-heavy tasks and calculations.

API Development
Application Program Interface Development, or referred easily to as API Development, deals with the
creation of libraries and modules to help developers create applications that can interact with a specific
application created by other developers. This breaks the barrier of using the existing utilities of a well-
known application to expand the capabilities of an application being developed. To make this clearer,
APIs are used to reuse services from web applications like the social media giant Facebook and the
search engine giant Google. API developers create a linkage for their applications for other to exploit like
using Google API to login in your application using your Google account, or Facebook API to
automatically post pictures to your Facebook timeline directly from your created camera application.
This domain is developer-friendly and is geared towards developers. Think of this as a module or library
created by developers for developers. Programming languages used in this domain vary on the base
programming language of the hosting application. However, heavy knowledge in JavaScript Object
Notation (JSON, read as Jay-son) and Extensive Markup Language (XML, read as ex-em-el). The
advantage of API Development over the other domains is its being developer-friendly and capability to
exploit existing services of running applications.

Embedded Systems Development


Embedded Systems Development deals with programming instructions to readily-made hardware
components, typically a microcontroller. Developing firmware can be considered as part of this domain
since firmware is developed for hardware. This domain is continually growing since a lot of major
companies and startups are moving towards the Cloud and Internet of Things (IOT). The Internet of
Things is a network of interconnected embedded systems through the internet. This includes basic
analysis of data coming from different sensors to advanced tracking of various sentries to create viable
predictions.

This domain is probably the most interactive among the rest since not only are you dealing with the
software side of the development, but you will also be engaging in the hardware aspects of the
development. In addition, a lot of automation can be done through Embedded Systems Development.
E.g. Home Automation, Automotive Automation and Industrial Automation. The programming languages
used primarily in this domain are C, C++, C# and Java.
ITE6102
COMPUTER PROGRAMMING

Infamous Programming and Scripting Languages


The data that will be presented from this point came from GitHub - the top open source repository in
the IT industry as of 2017.

JavaScript
a scripting language used for Web Development. It was first introduced by Brendan Eich in 1995 as an
attempt to add interactive user experience to static web pages in the Netscape Navigator browser. His
attempt paved the way to modern web applications where modules within the application can directly
interact with each other without requiring the page to reload for every action committed.

JavaScript is datatype independent, meaning you can insert any value of varying datatypes to its
variables. There no restriction in the usage of variables, hence its flexibility. Though many would argue
that such thing presents problematic consequences; this shortcoming was overcome by JavaScript
because of its being lightweight having no resource checking for variables. Some developers impose
naming convention for JavaScript to exploit variant datatype.

Because of the cleverness that JavaScript displayed during its time, various demands for adaptation have
risen. Ecma International Organization presented a standardization JavaScript for other browsers which
was called the ECMAScript.

Since 2000, JavaScript has been seen to have dominance over other languages present especially in Web
Development. Until now, JavaScript holds the Top 1 place in language usedat GitHub for 2016.

JavaScript, the scripting language, is not in any way related to Java the programming language. When
JavaScript was created in 1995, Java is already the most used programming language for client-side
applications. This famous scripting language was named JavaScript to capture the same success that
Java has during those times.

Java
a programming language developed by James Gosling, Patrick Naughton, Chris Warth, Ed Frank and
Mike Sheridan at Sun Microsystems in 1991. During this time, the internet and the World Wide Web
have made its way to conventional market where static web pages were used to present various
information to their users. Java was the successful attempt to bring dynamic forms in web pages.

Java was originally designed with a simple idea in mind - to create a portable platform capable of
running under different operating systems - which was promoted by their original slogan “Write once,
run anywhere”.

Suns Microsystem's original slogan is "Write once, run anywhere". However, due to the different issues
that surrounds Suns Java platform, which eventually refuted their claim of portability, Suns riposted
"Write once, debug everywhere".

Now, Java has made its way to different platforms including the original World Wide Web, enterprise
solutions, mobile devices and smart devices. Java ranked as Top 2 in the most used language in GitHub
as of 2016.
ITE6102
COMPUTER PROGRAMMING

Python
the first interpreted programming language. Python was designed by Guido van Rossum at Python
Software Foundation in 1991. It was designed with the idea of readability focusing on whitespace
indentation to define code blocks, going against well-known programming languages like C and C++ that
use curly brackets.

Because of the extensive library that Python has, it is generally used in machine learning algorithms and
application development. Several extensions have been created for Python to extend its features
including the ability to create graphical user interface. By far, Python ranks as the Top 3 most used
language in GitHub as of 2016.

Ruby
another interpreted programming language alongside Python. Ruby was designed and developed by
Yukihiro “Matz” Matsomoto in 1990 and was publicly released in 1995. Ruby is completely open
source. Developers not only receive free use of Ruby in their development, but they have the right to
copy, modify and distribute any part of Ruby as they like provided they keep it free-of-charge.

The idealization behind Ruby is “a scripting language that was more powerful than Perl, and more
object-oriented than Python,” as said by Matsomoto in “An Interview with the Creator of Ruby” in the
late 2001. Ruby sports its characteristic as a flexible language allowing the users to alter any part.
Unfortunately, Ruby is known to feature a single inheritance, so classes made cannot have more than
one parent.

But even though this small shortcoming, Ruby has a lot of implementations including Ruby on Rails
framework made for Web Development.

PHP
a sewer-side programming language written for Web Development. It was designed by Rasmus Lerdorf
and developed together with The PHP Development Team of Zend Technologies in 1994. The
abbreviation PHP originally meant Personal Home Page, but was changed to PHP Hypertext
Preprocessor.

PHP is an easy-to-use programming language in Web Development. It easily creates dynamic pages
ideal for time-constrained development. It also dynamically and programmatically generated images.
In addition, PHP has vast number of functions that include file interactions, uploading files, sessions and
cookies, and remote file handling. PHP remained Top 5 of the most used language in GitHub as of 2016.

C++
a general-purpose high-level lightweight programming language mainly used for Application
Development. C++ was designed by Bjarne Stroustrup in 1979. It can be called an extension of C
programming language equipped with object-oriented development paradigm, which was originally
called C with Classes. C++ earned its name in 1983 when the original C with Classes programming
language was added with derived classes, strict data typing inlining and default parameters. The "++" in
its name sewed as an indicator that C++ is the successor of the original C programming language.
ITE6102
COMPUTER PROGRAMMING

C++ still uses pointers and references which are originally available to C. In addition, a lot of code
optimization is present in C++ which kicks in during the compiling stage of the source code. Also, C++
supports both imperative paradigm and object-oriented paradigm.

The person credited for naming C++ as such is Rick Mascitti. He intended to use "++", an operator in the
original C programming language that means "+1", in the naming. His thoughts are that C++ is the newer
version of C.

C#
one of the programming languages that is both imperative and object- oriented. Released by Anders
Hejlsberg's team in 2000, C# is well-known programming language versatile for Application
Development, Web Development and Game Development. It is also now conquering the domain of
Mobile Development through Xamarin, to name one.

C# made its first appearance in Microsoft's Visual Studio.NET 2002. Its name was a wordplay like C++,
wherein the “#” indicates further increment of the value of C++; "#" is four (4) plus "+" signs.

Go
sometimes referred to as golang, is an open source programming language created at Google by Robert
Griesemer, Ken Thompson and Rob Pike in 2007. Go is a compiled programming language having the
same syntax as C. Go has been made a public open source project in 2009.

Go is ideal for Web Development and Application Development. Go sports concurrency, ease-of-use,
fast compilation, extensive security and efficiency features. Go also sports HTTP/2 Server Push which is
more secure and efficient that the previous versions HTTP/ 1.

Go programming language is currently growing in number usage which currently stands at Top 10 most
used languages in GitHub. GitHub is seeing a 93% growth in the number of pushes in their repositories.

Shell
a scripting language for Linux operating system which is run in the terminal of the system. Shell is a CLI
language capable of extending the running services by committing timely executed commands in the
terminal. There are a few versions of Shell including, but is not limited to, the Bourne Again Shell (or
bash), the C Shell (or csh), the remote shell (or rsh), the Korn Shell (or ksh) and the secure shell for SSL
telnet connections (or ssh).

Shell is used primarily by Linux Administrators and Network Administrators to manage the instances of
Linux distros over an enterprise architecture. Shell ranks Top 11 in GitHub's most used languages as of
2016.

Objective-C
another variant of the original C programming language with a new twist, addition of Smalltalk-style
message passing between processes. It was designed by Tom Love and Brad Cox in 1980.

Objective-C is an object-oriented programming language like C++; however, it sticks to adopting the
ideologies of the original C language. Objective-C ranks Top 12 of the most used languages in GitHub for
the year 2016.
ITE6102
COMPUTER PROGRAMMING

Objective-C is used by Apple as the main programming language that compiled to OSX and iOS
operating systems, and Cocoa and Cocoa Touch APIs

MODULE 2
Domains under Computer Development:
• Web Development
• Back-end Development
• Mobile Development
• Data Science
• Application Development
• API Development
• Embedded Systems Development

Infamous programming languages (2016):


• JavaScript
• Java
• Python
• Ruby
• Objective-C

Problem Solving
defined as the systematic approach in searching for a solution or set of solutions to a specific problem.
This approach can be in any form such as by listing the possible options and choosing the most efficient
of them, providing weights to all possible scenarios and choosing the most significant scenario, or
applying small-scale to massive calculations to incorporate values to challenges and optimally solve
those smaller challenges to complete the main problem. With addition of several other characteristics,
in the context of Computer Science, this can be called algorithms.

Problem Solving in Computer Programming


Problem Solving is the most essential skill that anyone venturing the field of Computer Programming
needs. It basically says whether a specific challenge is worth solving given a finite time. However, what
makes problem solving in Computer Programming different from the conventional problem solving are
the characteristics that a solution to the problem should have met. Problem Solving in Computer
Programming should satisfy the following characteristics:
• Solvable
• Goal-oriented
• Verifiable
• Quantifiable
• Doable in finite steps
• Doable in current technological limitations

Solvable
This characteristic might seem to be an obvious requirement, but tends to be overlooked in several
ways. A famous quote from a 2009 American comedy-drama film Up in the Air says, “It's only a
problem, if it has a solution.” This presents one aspect of solvable that focuses on the problem -
there should exist at least one probable solution. It is unthinkable to process problems that pose
no direct solutions. It is like playing NBA-sized basketball with tigers. That situation is designed for
ITE6102
COMPUTER PROGRAMMING

humans-only convention, whereas the subjects involved cannot in anyway be altered to satisfy the
need of the situation in this very moment.

Goal-oriented
A goal focuses the solutions to meet a specific one-path ending. Setting a goal to the problem-at-
hand lets you identify several approaches and solutions. It also set a few limitations to which
possible solutions are subjected to determine accept-reject criteria.

Verifiable
It is impractical to provide solutions for problems where you cannot even verify the validity of your
solutions. In addition, there is also the need to certify that there exist many other criteria to make
the solution fail and succeed. For example, we can have a slot machine that accepts only 5-peso and
1-peso coins be subjected to tests, wherein you can attempt to insert 10-peso, 5-peso, 1-peso and 5
-cent coins into the slot machine. The slot machine should then reject the 10-peso and 5-cent coins
in some defined way but accept the 5-peso and 1-peso coins.

Quantifiable
It is unworkable in Computer Programming if the problem cannot be quantified in any scale
possible. For instance, we have a problem which is about determining the acceptance rating of a
proposed Thesis title. This problem can be solved through Computer Programming provided a
qualifying criterion is provided. However, if tasked to provide solution for a problem to classify
which of the given inputs is fake and which is real.

Doable in a finite (number of) steps


We live in a world of limited resources. One of those resources concerned in Computer
Programming is time. It is highly impractical to provide a solution that takes a million of hours to
complete. In addition to time, computers have a limited amount of allocated resources, namely:
RAM, storage and processing power. Maxing out these resources just for a solution is not only
impractical but also useless.

Doable within the limits of the current technology


In computer programming, we simply reuse the resources currently at hand. Relying on other
resources that either does not yet exist or is impossible to get our hands on is proven to be
unintelligible. We do not concern ourselves with what will probably be available in the future since
Computer Programming aims for practicality over theory.

Flowcharts Essentials
Flowchart
a visual aid showing a sequence of actions or operations involved in Computer Programming. Flowchart
helps computer programmers in visualizing their thought solution which helps them visually relay their
low-level solution and helps to identify key aspects of the solution which can pose problems given a
specific combination of inputs, and Figure 1 shows a sample of a flowchart which illustrates the process
of going to school using one of the two transportation systems available, the bus and the subway.
ITE6102
COMPUTER PROGRAMMING

Leave home

Check time

Before
7AM?
Take bus Take subway

Reach school
Figure 2. Lau, J and Chan, J. (2017). [G05] Charts & Diagrams [Online Blog]. Retrieved from
http://philosophy.hku.hk/think/strategy/chart.php

The flowchart in Figure 2 shows almost all the fundamental used in flowcharting. That flowchart solves
the problem of going to school by choosing an appropriate transportation system based on time.

The flowchart starts with the student leaving home. After leaving, the student needs to choose the best
transportation system he will take to arrive at his school.

Based on the given flowchart, we can assume that there is a heavy buildup of traffic past 7 AM. It is
therefore a better choice to take the subway if the time is past 7 AM.

If it is 7 AM, he can choose bus as his transportation vehicle. If it is already past 7 AM, he needs to take
the subway to arrive at school on time. After taking the best transportation system, the flowcharts end
with the student arriving at school on time.

You might have noticed that the flowchart uses two distinct symbols for checking the time and deciding
what action to do. This is essential in Computer Programming. You need to learn how to identify
distinct actions. The act of checking the time is totally different from deciding which action to do.
Although, it is tempting to simply combine the two actions, the computer will still read them as two
distinct actions. Hence, as a promising computer programmer, you need to be able to personally
identify such easily missed distinctions and act accordingly as how the computer will interpret those
instructions. Knowing this will not only make your codes easy to read, but also optimize your codes.

Symbols used in Flowcharts


Flowcharts use a defined set of symbols to represent a specific action performed. Those symbols are
used like how you will use Lego bricks to build something. In Computer Programming, those symbols
are combined in a specific manner to build an application, for example. One thing to note for the
symbols is like a set of Lego bricks, symbols should be used in a manner that fits the requirements of
the solution to create a logical flow of actions (i.e. instructions for the computer).
ITE6102
COMPUTER PROGRAMMING

Symbol Name Description


A symbol used to indicate the beginning or the end of
Terminator
the process flow
Process A symbol used to indicate a specific action done

Preparation A symbol used to prepare data or initialize something


A symbol used to retrieve value from the user as
Data
input or present value to the user as output
A symbol used to identify which of the two possible
Decision
paths will be taken based on the conditions set aside
A symbol used to connect two or more symbols
On-page
belonging to the same page together to form a
Connectors
continuous process
A symbol used to connect two or more symbols
Off-page
belonging to the different pages together to form a
Connectors
continuous process
Table 2. Basic Symbols in Flowcharting

The symbols in Table 1 are connected by a line with one and only one arrow head, usually called arrow.
In Mathematics, this is a ray with no suggestive prominent endpoint. The arrow head determines the
flow of the process, where next symbol to read is.

Process 2 Process 1
Figure 3. Partial Flowchart Showing the Progression of Symbols
Figure 3 shows the progression of symbols using the arrow. In the figure, Process 2 is executed first
before Process 1 despite their naming. The arrow is the sole indicator of the progress.

A Process 1

Process 2

Process 3

Process 4 A

Figure 4. Partial Flowchart Showing another Progression of Symbols


Figure 4 shows a more complex progression using arrows. In this figure, Process 1 is executed first,
followed by Process 2, then Process 3. In Process 3, the arrow points to Process 4 which is pointed back
to Process 1. This specific example is a non-terminating process which should be avoided in actual
programming design.
ITE6102
COMPUTER PROGRAMMING

Standards in Flowcharting
Now that you know the different symbols used in creating your flowcharts, you need to adhere to the
standards used in writing. In this section, you will learn the different standards in which should aid you
also in writing your codes in the future. These standards were set not to limit you with the usage of the
symbols, but to give you freedom in setting your logic for writing computer instructions through
computer programming.

Process 1

Process 2
Figure 5. Start Terminator and End Terminator
Flowcharts should always have two (2) and only two terminator symbols, namely the Start terminator
and the End terminator. The Start terminator always starts the entire flowchart sequence. It should
always be the first symbol found at the top. Most of all, if the flowchart sequence is multi-paged, the
Start terminator is found at the first page. The End terminator always ends the entire flowchart
sequence. It should always be the last symbol found at the bottom. Most of all, if the flowchart is multi-
paged, the End terminator is found at the last page.

Is 1>2 No

Yes
Figure 6. Decision Symbol with Yes and No Scenarios
Decision symbols always have two (2) possible scenarios: the YES and NO. Since the Decision symbol
contains a specific condition, that condition should always be answerable by YES or a NO. If the
condition is not answerable by a YES or a NO, the condition should be rephrased to adhere to standard
regardless of the number of nested Decision symbols to be made. This is the case for the Decision
symbol, since the computer can only process one condition at a time. For example, if you asked “which
color did the user pick?”, the computer will process that with a series of questions like “Is it Blue?”, “Is it
Red?" and so on. The computer will not directly check for the answer like “The user definitely chose
Red” without checking for the rest of the possible answers.

Inputv

Figure 7. Data Symbol with Outgoing Arrow

END
Figure 8. End Terminator without any Outgoing Arrow
ITE6102
COMPUTER PROGRAMMING

Flowchart symbols should always have one (1) and only one out-going arrow. Since the arrow signifies
that there is a progression of flow, it is a requirement that symbols should only have one arrow to other
symbols. We are limiting our thinking to single-threaded flow. Hence, a symbol can only be succeeded
by only one symbol. The exceptions to this are the End terminator and the Decision symbol. The End
terminator marks the end of the flowchart; therefore, there is no logical need for it to have an arrow.
The Decision symbol has two possible scenarios; therefore, there are always two (2) and only two
arrows.
START

x=1+1

END
Figure 9. Flowchart Layout

Flowchart symbols can have any number of in-going arrows. Since most symbols can start from any of
the other symbols, it is logically accurate to allow any number of in-going arrows. However, there is only
one (1) symbol that does not allow any in-going arrow - the Start terminator. The Start terminator marks
the start of the entire flowchart; therefore, there is no logical reasoning to connect other symbols to the
Start terminator. Should there be a need to restart the entire flow, the symbol should connect to the
symbol with an in-going arrow from the Start terminator.

Flowcharts are written from top to bottom. With the Start terminator at the top, the next symbols
should be placed below the Start terminator, and the next below the previous symbol. There exist some
symbols beside a symbol, which is the case for the Decision, On-page Connector and Off-page
Connector symbols.

Flowcharts should not have any out-going arrow pointed upwards. This is for creating a seamless flow
process. For complex flowcharts supporting upward out-going arrows, determining the connection
between the symbols will prove to be difficult. Hence, there is the need for this standard. Should there
be a need to connect to other symbols found at the top of the sequence, you can use On-page and Off-
page Connector symbols.

Lastly, flowcharts should not have any overlapping arrows. This is for emphasizing clarity. Having
overlapping arrows creates ambiguity in the direction of the arrows intersecting and their respective
symbols.

Pseudocodes
Pseudocodes are not Academe-standard for expectant undergraduate students. However, there is a
growing demand in the usage of pseudocodes not only in the Academic sector, but also the Research
sector. Pseudocodes are high-level description of the processes in Computer Programming. Their
format varies by writer. Some are English-like to accommodate non-technical audience. Some are
written close to the actual syntax used in the source code to accommodate technical audiences and
Research critics.
ITE6102
COMPUTER PROGRAMMING

DECLARE name
SET name AS “Charlotte”
APPEND “Queens” TO name
APPEND “B.A.” TO name
OUTPUT name

Pseudocode are generally user-centric and no defined standard for writing them.

Keyword Usage Description


DECLARE DECLAREv, a [] A keyword to signify we are about to
declare a variable v and an array a

NOTE: Think variable as a word that


represents something, and an array as
word that represents a series of
anything.
SET … AS… SETvariable1ASvalue1, A keyword to set values to variables
variable2ASvalue2
APPEND … TO… APPENDvalue1TOvariable1, A keyword to insert String values at
value2TOvariable2 the end of a variable containing a
String
IF … THEN … IFcondition1THENstatements1 A keyword to limit selected
END statements from being executed only
(ELSE IF … THEN … when the specified condition was met
ELSE…) or

END IFcondition1THENstatements1
ELSEstatements2
END

or

IFcondition1THENstatements1
ELSE IFcondition2THENstatements 2
ELSEstatements3
END
WHILE … DO WHILEcondition1DOstatements2 A keyword to limit selected
… LOOP statements from being executed
LOOP repeatedly until the specified
condition becomes false
OUTPUT … OUTPUTvariable/value A keyword to display a value or a
value of a variable to the user
INPUT … INPUTvariable A keyword to accept any value from
the user and save it to a variable
CALL … CALLfunction/subroutine A keyword to call a user-defined or
external function
Table 3. Pseudocode Keywords
ITE6102
COMPUTER PROGRAMMING

PROBLEM SOLVING

• Scenario 1: One of our daily routines is eating. However, you can only eat if there is food already
prepared for you. If there are none, you should cook food on your own before you take a big gulp.

Start

Is food No
prepared? Cook food

Yes

Eat

End

Foodlntake()
DECLARE isFoodPrepared
SET isFoodPrepared TO ChecklfFoodlsPrepared()
IF NOT isFoodPrepared THEN
CALL PrepareFood()
END
CALL EatFood()
END
ITE6102
COMPUTER PROGRAMMING

• Scenario 2: “Is it the weekends?” That is one of the questions we ask ourselves daily. We wake up
in the morning, check if it is the weekends already. If it is, we sleep again. Or else, we take a bath.

Start

Wake up

No
Weekends? Take a bath

Yes

Sleep

End

WeekendRoutine()
DECLARE isWeekends
SET isWeekends TO ChecklfWeekends()
IF isWeekends THEN
CALL Sleep()
ELSE
CALL TakeBath()
END
ITE6102
COMPUTER PROGRAMMING

• Scenario 3: We are given chores depending on the day. On weekends, we are tasked to do the
laundry. On weekdays except Friday, we are tasked to do a general cleaning. On Fridays, we are
tasked to a grocery spree.

Start

No No
Day is Saturday General
Day is Friday?
or Sunday? cleaning

Yes Yes

Laundry Grocery

End

DailyChores()
DECLARE day
SET day TO GetDay()
IF day=“Saturday” OR day=“Sunday” THEN
CALL DoLaundry()
ELSE IF day=“Friday” THEN
CALL DoGrocery()
ELSE
CALL DoGeneralCleaning()
END
ITE6102
COMPUTER PROGRAMMING

• Scenario 4: As students, we were forced to a study habit. On weekdays, we are to study our
lessons. On weekends, we are free to play with the computer. After studying and playing
computer games, we still have time to watch television.

Start

No
Weekdays? Computer

Yes

Study

Watch
television

End

StudyGamesAndEverythingNice()
DECLAREisWeekend
SETisWeekendTOGetIsWeekend()
IFisWeekendTHEN
CALLDoStudyLesson()
ELSE
CALLDoPlayComputer()
END
CALLDoWatchTelevision()
ITE6102
COMPUTER PROGRAMMING

• Imagine a huge house with a beautiful garden. With that, you need to ensure the garden is kept
well-maintained. If it is messy, you should do something about it. If you are the owner, call the
caretaker to do the gardening; if not, do the gardening yourself.

Start

No
Messy
garden

Yes

Yes
Are you the No Call the
gardener? gardener

Yes

Start
gardening

End

GardenOhMyGarden()
DECLAREisGardenMessy, amIOwner
SETisGardenMessyTOGetIsGardenMessy()
SETamIOwnerTOGetAmIOwner()
IFisGardenMessyTHEN
IFamIOwnerTHEN
CALLCallGardener()
ELSE
CALLDoGardening()
END
END
ITE6102
COMPUTER PROGRAMMING

MODULE3
Understanding the logic applied to is easy, but writing one that complies to all the standards, and have a
sound and efficient design does not come as easy as any would think. It often requires a low-level
understanding of the problem and all relevant implications surrounding it. Given that we understand the
problem, we will still need to generalize the identified solution to cover all iterations of the problem in
such a way that our solution will always return our expected result back to the user. The flowchart design
should also consider all possible inputs based on the scope of the problem regardless if the scenario
implied was covered in the initial given.

Understanding the Problem


• Understanding the problem is the first step in composing an efficient and working flowchart
design. Before considering to solve the problem-at-hand, the problem should satisfy the
characteristics:
o Solvable
o Goal-oriented
o Verifiable
o Quantifiable
o Doable in finite steps
o Doable in current technological limitations

*Always keep these in mind before understanding the problem.

To understand a given problem in Computer Programming perspective, it is essential to identify keywords


and categorize them into steps as technical work items. Technical work items are short keyword-driven
phrases which summarizes all the essential parts of the problem we put into consideration. They are
guided using the following characteristics:
• Concise
• Unambiguous
• Classifiable: INPUT, PROCESS or OUTPUT
• Specific

Concise. Having a shortly written work item helps us identify exactly what needs to be accomplished.
This will enable us to not only work directly on the solution, but it will also discourage us not to divert
from our identified solution.

Unambiguous. This characteristic emphasizes on one important thing – the simplicity of how the
work item was written. The work item should guide you to complete your identified solution without
compromising on too many variables, such as the number of steps for the solution. In addition, the
work items should be direct to the solution itself.

Classifiable. Namely, INPUT, PROCESS and OUTPUT.


INPUT work items
those that require user intervention and asks for some actions from the user.

PROCESS work items


those that the computer itself will do like perform some series of computations.
ITE6102
COMPUTER PROGRAMMING

OUTPUT work items


those that requires the user to recognize a result coming from our program; also, those that
could be a computer-interpretable result on which the computer will read it and not the user.

Specific. Each work item should point to only one thing that needs to be accomplished, may it be to
ask the user for his first name or last name but not both. In case there is the need to ask for the two
information, there should be one of each; one for the first name and one for the last name. There
should not be more than one task for one work item.

Sample Problems

Let us take this simple problem as our initial example:

“Write a program that displays ‘Hello World’.”


Figure 1. Problem 1 – Hello World

The above problem is simply asking us to display a series of specified text to the user. It does not include
any requests for the user to enter values to our program. The solution to this problem lies on outputting
the text “Hello World” to the user then our program ends.

Not much of a challenge yet. The next problem will cover asking the user to enter values for our
program to execute.

“Write a program that adds two numbers from the user.”


Figure 2. Problem 2 - Addition

This second problem is more complicated compared to the first one. Let us dissect first what the
problem is all about. The phrase “add” suggests that we will be needing to ask the computer to perform
some calculations. This calculation, however, is limited to addition and nothing more.

This is supplemented by the phrase “two numbers” which suggests that we are only to perform the said
calculations on two specific numbers. In addition to this, we are assured that the inputs are all numerical
values.

Though, the problem is vague in one thing – the kind of number that we are to deal with. Do we need to
accept only integers? Do we need to accept only floating points? Since the problem is vague, we should
interpret it as if the problem requires all kinds of numerical inputs – integers and floating points.

Lastly, the phrase “from the user” suggests that the two numerical values will be coming from the user.
We do not need to concern ourselves with inputs using parameters and file inputs.

Let us have another more complicated example.

“Write a program that reverses a string input from the user.”


Figure 3. Problem 3 – String Manipulation
ITE6102
COMPUTER PROGRAMMING

This problem does not look too much complicated in functional sense. However, in the computer’s
perspective, this requires a lot of work. This is because of how the computer processes strings.
Computers do not read strings like how we read them. Computers see them as a series of precise
characters and nothing more. That is why, to reverse a string, the computer needs to read each
character of the string starting from the last character until the first character and storing them to
display to the user.

Not yet making sense? Let us look at an analogy of this. Let us picture you have a purse hidden in your
pocket containing various denomination of coins. You need to categorize them by denomination. How
do you do this? You take the purse out of your pocket and start to take one coin at a time. Upon each
take, you check the value of the coin and categorize them accordingly. Notice how you need to take one
coin at a time to accurately categorize them? That is like how the computers treat strings.

Now back to the problem. Our main objective is to reverse a given string as suggested by the phrase
“reverse a string”. Reversing a string means reading each character from the end to the beginning of
the string.

And, as suggested by the phrase “string input from the user”, the string will be coming from the user.
We need to support the user like the previous problem; the input will be solely governed by user inputs
and not file inputs.

Sample Technical Work Items


Now that we have our set of problems with accompanying discussion on how to interpret the problem,
we now need to work out our technical work items that we will follow to accomplish our identified
solution. Note that this process can become purely a mental procedure without the need of outlining
the work items. However, to guide you on how to correctly formulate your work items and in doing so,
we are avoiding compromises on the limitations of the computer, we will need to outline them point-by-
point.

Let us begin using Problem 1. We argued that Problem 1 is solely about displaying the string “Hello
World” to the user. Hence, we have a simple work item:

1. To display “Hello World”


Figure 4. Technical Work Items 1 – Hello World

Simple, is it not? Since we do not need any input coming from the user, we do not place any work item
for inputs. Since we do not have anything to process computationally, we do not place any work item for
process. We only allotted one work item and that is for displaying a fixed string “Hello World”.

Let us look at Problem 2. We argued that we will need to ask the user to enter some values; two
numbers to be exact. In addition, we need to perform a simple calculation over the two entered
numbers. We need to add the two entered numbers and display them back to the user. Take note that
since we are displaying a simple calculation back to the user, we can combine the two as one single
process.
Creating the work items for Problem 2 will result into something like this:
1. To ask user for the first number
2. To ask user for the second number
ITE6102
COMPUTER PROGRAMMING

3. To display the sum of the two numbers


Figure 5. Technical Work Items 2 – Addition

As you can notice, we dissected the request for user input into two since our solution will need two
numbers from the user. The third and last work item will display the sum of the two numbers. Since the
output does not require any complex operations, we have combined the actual displaying with the
summation of the two numbers.

Familiarizing yourself with the limitations of computers will warrant you to create a more fluid and
efficient program in the future.

This gets more complicated as we tackle Problem 3. In Problem 3, we argued that we will look at each
character of the entered string of the user. This is how we can take each character and reverse them by
displaying the characters of the string using the last character first.

1. To ask user for a string


2. To determine the length of the string as x
3. To check if x is greater than 0
4. To end processing if Work Item 3 is a no
5. To display the xth character
6. To subtract 1 from x
7. To return to Work Item 3 to continue processing the rest of the characters
Figure 6. Technical Work Items 3 – String Manipulation

As you can see, we have added a rather complicated setup to our previous solution. Work Item 1 is
simply asking the user to enter a string that our program will process. Now to display the last
character, we will need to know how long the entered string as covered in Work Item 2 was. This step is
seemingly tedious but you need to understand that this is how computers work. Computers cannot
directly determine the position of the last character. We need to direct it.

Work Item 3 is simply a conditional to determine whether it is logical or still logical to continue. This is
supported by the succeeding Work Items after it. Work Item 4 ends our program execution since by
then we will have determined the length x to be zero. And the zeroth character of a string is nothing.
Make sense?

Work Item 5 is about the actual display of the character. As discussed previously, we will be displaying
the last character of the string with the help of the determined length x. Work Item 6 is to prepare for
the next character to display. Lastly, Work Item 7 is just instructing us to repeat the steps starting from
Work Item 3.

Does not make sense? Let us look at this closer through an example. Let us say we have a string
“computer”. The length of the string is 8. Now, the 8th character of the string is “r”. We then display “r”
back to the user. We subtract our determined length by 1 to get 7. Now, the 7th character of the string
is “e”; we display “e”. Is it a little bit clearer? Now, we again subtract 1 from our determined length and
get 6. Display the 6th character ‘f’. We do this until let us say we have our determined length reduced to
3. The 3rd character is "m". By this time, we have already displayed the string “retupm” to the user. If
we continued until we get 1, we have already displayed “retupmoc”.
ITE6102
COMPUTER PROGRAMMING

As you will see, since our determined length is reduced to 1. Because of Work Item 6, we reduce it again,
so we now have 0. Work Item 7 instructs us to repeat Work Item 3 which checks if our determined
length is 0. Since it is already 0, Work Item 4 takes over and end our execution.

Beginning from Work Item 3 until Work Item 7, we repeatedly executed the work items until our
condition in Work Item 3 is not anymore satisfied. This in computer programming is called an "iteration".
One pass through the sets of Work Items 3 to 7 is called "one iteration".

After identifying a set of Technical Work Items that we need to do for every problem that we are given,
we can now create our flowcharts. Flowcharts are our way to visualize the solution that we come up
through the technical work items. In comparison to the technical work items as the written logical side
of our solution, we can look at flowcharts as the visual side. We focus on diagrams and symbols to
represent our logic.

Let us take our Problem 1 as our primary example. Figure 1 shows one version of our Technical Work
Items 1 if visualized as a flowchart.

START

Display
“Hello
World”

END

Figure 7. Display “Hello World”

Remember that we begin and end our flowchart with the START and END terminator. In
between the two is our actual logic by utilizing the different symbols used in flowcharting.
Following the START terminator, we have a display symbol which we used to materialize Work
Item 1 “To display ‘Hello World’”. We do not have any other symbols in between since Problem
1 does not ask for any other things for us to do.

Our Technical Work Items 2 contains 3 work items within. Let us look at Figure 2, a version of a
flowchart for the Problem 2 solution.
ITE6102
COMPUTER PROGRAMMING

START

Accept
num 1

Accept
num 2

Display
num 1 +
num 2

END

Figure 8. Displaying the Sum of Two Numbers

After our START terminator, we ask our user to enter a number and we store it as num 1.
Remember that when we ask a user for an input, we immediately store it to a temporary
container we call variable. Think of variables as a temporary container for values; whether
entered by the user or added by ourselves.

Following that is we again ask the user for another number. We then stored it again to another
variable named num2. We used a separate variable to avoid overwriting our previously created
variable num1. Think of it this way, we have two different drinks. Let us say a water and a soda.
We need to pour those drinks to a cup. However, it is illogical to use only one cup for both
drinks. We can place the soda in the same cup if we empty it first. But by emptying the cup, we
lose the previous drink. And we do not want that in our program. We need to keep the value
until the end of our program. Therefore, we use two different variables, num 1 and num2.

Lastly, we have a display symbol which contains the sum of num1 and num2. Notice here that
we did not anymore create a third variable num3. This is because we do not need the sum
anymore after displaying its value. We only use variables if we intend to keep them for future
ITE6102
COMPUTER PROGRAMMING

use. In this instance, we do not need num3 because as soon as we displayed the sum, we
terminate the program through the END terminator of flowchart.

There is a special kind of variable called "arrays". Arrays contain "vector values"; hence, they can
store more than one value. Typically, they are used as a one-dimension figure. However, there
are cases when two-dimension and three- dimension arrays are more applicable.

The last problem covers reversing an input string. And as we have previously argued, this is not
as simple as we read it. Figure 3 shows a version flowchart version of our Technical Work Item 3.

START

Accept
str 1

Store in x the
number of
characters of
str 1

Display
No the xth
x=∅ x=x-1
character
of str 1
Yes

END

Figure 9. Displaying the Reverse of a String

Figure 3 starts with accepting input from the user. Like Figure 2, we store the string input to a
variable named str1. After which, we determine the length of str1 and store it to another
variable named x. By this time, we have two different variables; a string variable str1 and a
numerical variable x.

The fourth symbol, the conditional, tests our variable x value. Since we will retrieve only the
existent characters of the string, we will proceed to END terminator if the length is now zero.
While it is yet to be zero, we will retrieve the xth character of the string str1. Once we have
retrieved the character, we display it to the user then proceed to the next operations.
ITE6102
COMPUTER PROGRAMMING

The next symbol is a process symbol. Since we are only to perform Mathematical computation
against the variable x, we use process symbol. We subtract one from the value of x to get the
next character. After this, we return to the fourth symbol and repeat the entire iteration again.

We can also create equivalent pseudocode representation. The pseudocode will be your closest
tool to writing the actual codes itself.

Pseudocode for Flowchart 1


Flowchart 1 is devised to display the string “Hello World”. So, we will only use the OUTPUT
keyword of our pseudocode convention.

OUTPUT “Hello World”


Figure 10. Pseudocode for Hello World

Notice how we enclosed the string “Hello World” in quotation marks? This is to convey that the
Hello World is a string literal and not anything else (i.e. variable). This practice is prevalent to all
programming languages and hence we also adopted this practice even in writing our
pseudocodes.

Pseudocode for Flowchart 2


Flowchart 2 is devised to display the sum of two numbers from the users. For this we will use an
additional keyword INPUT.

DECLARE num1, num2


INPUT num1
INPUT num2
OUTPUT num1 + num2
Figure 11. Pseudocode for Addition

In this translation, we used the keyword DECLARE to define our variables. This is a necessity
when we use variables. It is advised to declare all variables as our first line in our pseudocode.
You might argue why we did not anymore separate the two variables in two distinct DECLARE
codes. This is because of our convention. We defined earlier that we can declare more than one
variable in one line. This practice is almost like actual programming. The only difference is that
this practice is applicable only for variables of the same types.

The next two INPUT keywords are expected. We ask the user for values, which is limited by the
problem to be numerical in nature, and store them to their corresponding variables. The last
keyword is solely to display the sum of num 1 and num 2.

Pseudocode for Flowchart 3


Flowchart 3 is devised to reverse a given string and display it back to the user. We are taken
aback by the number of operations we need to do for this problem. Good thing we already have
a flowchart to guide us. Flowchart 3 would have an equivalent pseudocode as follow:
ITE6102
COMPUTER PROGRAMMING

DECLARE str1, x
INPUT str1
SET x TO GetLength (str)
WHILE x > 0DO
OUTPUT str[x- 1]
SET x TO x - 1
LOOP
Figure 12. Pseudocode for String Manipulation

In this pseudocode, we have used to WHILE DO LOOP keyword which is used for iterations. The
behavior of the Technical Work Items and Flowchart for Problem 3 which return to a specific
point in the design is called an iteration. We used the WHILE DO LOOP keyword since that
section is an iteration.

The pseudocode started with the declaration of the variables str1 and x. We then populate the
variable str1 with the value from the user. Then we populate the variable x with the value from
GetLength() which retrieves the length of str1 . After which, we proceed with the iteration
where we check first if the value of x is greater than zero. Since initially that statement is true,
we proceed to the OUTPUT keyword which displays to the user the last character of the string.

Notice we used str[x - 1] and not str[x]. This is because the computer counts characters from 0
and not 1, wherein the character is the first character of the series.

Lastly, we deduct 1 from the value of x and store the difference back to x. Here, we are recycling
the variable x since we are only tracking the changing character of the string str1. The iteration
to the WHILE DO LOOP keyword until after the first character of str1 has been displayed.
ITE6102
COMPUTER PROGRAMMING

Problem Solving
Question: Write a program that accepts an integer input from the user and display the least number of
combinations of 10s, 5s, and 1s.

We start of by using START terminator.


START
Next, we use the Preparation symbol to declare our
variables. We will be needing three variables for our
computations.
DECLARE userValue,
remainingValue,
The userValue variable will contain the number entered by
temp
the user.

The remainingValue variable will contain the remaining


values after they complete the necessary computations.
INPUT
userValue The temp variable will contain the result of the
computations. This variable will also be used to display to
the user per combination.
remainingValue =
userValue Next, we start our processing by accepting an input by using
the INPUT Data symbol. We store the input to the userValue
variable.

1 We then initialize remaining value variable with the value


stored in the userValue. This preserves the input from the
user.
ITE6102
COMPUTER PROGRAMMING

temp = remainingValue = OUTPUT “There


remaingValue
remainingValue / remainingValue are” + temp +
> = 10
10 − temp “10’s”

Next, we check if the remaining value is greater than or equal to the largest denomination, 10. We do
this because we do not need to display that we do not have 10 denominations.

Now we get the number of 10’s in our remaining value by dividing the remainingValue variable by 10.
We store the quotient to the temp variable.

Since we know the number of 10’s in the remaining value, we need to determine the remainder by
subtracting the remaining value and the quotient, temp. We store the remainder/difference to our
remainingValue variable.

We display the quotient as a concatenation of the string “There are “…” 10’s” through the variable temp.

temp = remainingValue = OUTPUT “There


remaingValue remainingValue / remainingValue are” + temp +
>=5 5 − temp “5’s”

OUTPUT “There are”


+ remainingValue +
“1’s”

END
ITE6102
COMPUTER PROGRAMMING

Now check if the remaining value is greater than or equal to the largest denomination, 5. We do this
because we do not need to display that we do not have 5 denominations.

Next, we get the number of 5’s in our remaining value by dividing the remainingValue variable by 5. We
store the quotient to the temp variable.

Since we now know the number of 5’s in the remainingValue variable, we need to determine the
remainder by subtracting the remaining value and the quotient, temp.

We store the remainder/difference to our remainingValue variable.

We display the quotient as a concatenation of the string “There are “…” 5’s” through the variable temp.

We will display the number of 1’s we have through the variable temp. Lastly, we will end our
computation using the END terminator.

MODULE4
In the previous module we identified variables and data types. We also enumerated the classifications of
variables namely:
a. Explicit Variables
b. Implicit Variables
c. Anonymous Variables

We also enumerated the classifications of data namely:


1. By Value
a. Explicit Data Types
b. Implicit Data Types
2. By Construct
a. Primitive Data Types
b. Referenced Data V pes

Lastly, we identified the data types within C++, namely:


1. Integer Values
a. Signed Integers
i. [singed] int
ii. [singed] short
iii. [signed] long

b. Unsigned Integers
i. unsigned int
ii. unsigned short
iii. unsigned long
2. Floating-point Values
a. float
b. double
3. Boolean Values
a. Bool
ITE6102
COMPUTER PROGRAMMING

4. Character Values
a. char
b. string

Introduction to Code Blocks


Code Blocks are a series of programming statements that are grouped together. They are located
within the curly brackets/braces, opened by ({) and closed (}).

Let us look at Figure 1, a sample of our Hello World example from Week 004.

Figure 1. Hello World! Source Code

We have enclosed actual code logic inside a code block. This code block belongs to "int main( )"
function. It means everything inside belongs only to the code block of "int main( )" function.

Variables
Since we are talking about code, we need to discuss various things about variables and how they are
affected by code. We have global variables and local variables. Global variables are variables declared
outside of the "int main( )" function. They are usable anywhere in the same line of the declaration, and
within the code like the "int main( )" function code block. Local variables are variables declared within a
specific code block and is accessed and used only within the said code block.
ITE6102
COMPUTER PROGRAMMING

Figure 2. Global and Local Variable Source Code

In Figure 2, we have two variables, globalA and localA. In this example, global A is a global variable. It
means globalA is usable anywhere in the source code. Our localA variable is a local variable which
means that it is only usable within "int main( )” function.

We only have covered the declaration and retrieval part of variables, but how about assignment? We
can always assign values to our variables as long as we can retrieve their value. In addition, the value we
stored in that variable stays with the variable even if the code block where it was done is exited.

These scenarios will be clearer once we have written our first non-standard code block, a conditional.

Introduction to Conditionals
Conditionals are the means to set a different set of statements based on conditions. They let us expand
the capabilities of our applications through scenarios or states. In C++, we have two (2) conditionals,
namely: the ifs and the switches.

If Statements
Ifs are used when we have an undefined conditional expression, may it be a single or multiple
expression.
ITE6102
COMPUTER PROGRAMMING

Figure 3. If Statement

In Figure 3, we placed an IF conditional between lines 12 to 16, inclusively. Line 12 shows the actual if
statement wherein the condition we set is a constant. Remember that positive-valued integers are
treated as always true. Therefore, in this case, lines 13 to 15 will always be executed. For example, in
line 12, we have the value 0 instead of 1, then the lines 13 to 15 will never be executed. Therefore, it is
imperative that the conditions within the IF conditional evaluate to true in order for the statements
within the code block to be executed.

Again, in Figure 3, we introduced another local variable localB in line 13. Variable localB is only
accessible within the IF code block (lines 12 to 16). Therefore, since we called the localB variable in line
20, the application when compiled will return an error. The code block of "int main( )" function does not
know about localB.

Lastly, again in Figure 3, we assigned a value of 20 to localA. As discussed above, the value 20 will retain
to localA as long as the IF statement in line 12 is executed. Therefore, should the application m n, the
value to be displayed for localA will be 20 and not its initial value of 2.

Now, what if we want to handle a scenario wherein our initial IF statement evaluates to false? We can
use the IF…ELSE statements.
ITE6102
COMPUTER PROGRAMMING

Figure 4. If-Els e Statement

In Figure 4, we introduced the else statement in line 17. The else code block from line 16 to 18, will only
be taken in consideration should the IF statement evaluates to false. In this specific example since line
12 is always true, lines 16 to 18 will never be executed.

Again, if we modify our line 12 to always evaluate to false (e.g. “if (0) {“), then our line 16 to 18 will
always be executed. Just remember that the “ELSE” statements will only be executed if the “IF”
statements before them are not executed.

Lastly, how about if we have more than one condition to consider? Then we can use a compound IF
statements.

Code optimization helps developers create a seamless application execution. You may learn more about
the topic through the course about “Assembly” languages.
ITE6102
COMPUTER PROGRAMMING

Figure 5. If-Els e If-Els e Statement

Figure 5 introduces to how to use the compounded “IF” statements. In addition, we have modified our
original source code to something more meaningful. What we did here is we declared two local
variables, namely: "a" and "b". Variable "a" is initialized as an integer with a value of 123. Variable "b" is
initialized as an integer with a value of 1. In this example, we have three statements for our conditional
in lines 11, 13 and 15.

Now let us evaluate our application, in line 13 we evaluate whether the value of variable "b" is equal to
exactly 1. Since this is always true, the value of variable "a" will be multiplied by 1. Therefore, cout line
19, the value of variable "a" is still 123.

If we modify our application and changed the initial value of variable "b" to 2, and execute the
application, we will have:
• Line 11 will evaluate to false since variable "b" is not equal to 1.
• Line 12 will not be executed.
• Line 13 will evaluate to true since variable "b" is equal to 2.
• Line 14 will be executed.
• Line 15 will not be passed by since line 13 is already executed.
• Line 16 will not be executed.

If we modify our application and changed the initial value of variable "b" any value except 1 and 2 (e.g.
"int b = 3"), and execute the application, we will have:
• Line 11 will evaluate to false since variable "b" is not equal to 1.
• Line 12 will not be executed.
ITE6102
COMPUTER PROGRAMMING

• Line 13 will evaluate to false since variable "b" is not equal to 2.


• Line 14 will not be executed.
• Line 15 will be executed since lines 11 and 13 evaluated to false.
• Line 16 will not be executed.

Noticed how the value of variable "a" is affected by what the value of variable "b" is? This is a simple
demonstration of the power of using conditionals.

Switch Statements
Another of the conditionals are the switch statements. Switch is a conditional that compares one
specific variable against a set of defined constants or values.

Figure 6. Switch Statement

A switch statement is staffed with the “switch(variableName) {“syntax and ended with a closing
bracket”}”. In between are the possible values for the “variableName” preceded with a “case”
statement and ended by a colon “:”. For example, in line 12, variable “b” has a possible value of “1”, so
we wrote “case 1:”. Followed by it are the statements that will be executed only when the value of “b” is
“1”. That may be any number of statements. Notice that almost all “case” statements are ended by a
“break;” statement. This is because, in switch, breaks end the execution of that specific value.

Let us take lines 18 and 19 as our example. “case 3:” does not have any “break” statements, therefore if
the value of the variable “b” is 3, it will execute all the statements under it and proceed to the next case
statement, the “case 4:”. The execution of “case 3:” does not end at “case 3:”, it proceeds to “case 4:”
and executes it regardless if the value of variable “b” is not 4.
ITE6102
COMPUTER PROGRAMMING

For this to make more sense, let us change the value of variable “b” to 3. What will be the displayed
value of variable “a”?
a. 123
b. 246
c. 369
d. 1230

The answer is “C”. The switch statement will jump to “case 3:” since the value of variable “b” is 3.
However, since there are no break statements under “case 3:”, the statements under “case 4:” will be
executed. Hence, we have variable “a” multiplied by 3 resulting to the value to be 369.

The last thing we need to consider under SWITCH statements is the DEFAULT statement. It is an optional
statement under SWITCH which is executed should all of the CASE statement evaluate to false. If we set
the value of variable “b” to 5, the statements under DEFAULT will be executed.

SWITCH statements are two-folds faster than IF statements. This is because of how compilers translate
SWITCH statements to machine code. If you reverse engineer a SWITCH and an IF statement, you will notice
the switch evaluates to JMP statements whereas the IF evaluates to one of the comparisons IF statements
in Assembly.

Nesting of Conditionals
It is possible to create a nested conditional depending on the need. You can create an IF within an IF
statement. You can create a SWITCH within a SWITCH statement. You can also create a hybrid of IF
within a SWITCH, or a SWITCH within an IF. These combinations mainly depend on your need as a
developer.

Figure 7. Nested Conditionals


ITE6102
COMPUTER PROGRAMMING

Consider this example in Figure 7, we used a SWITCH statement within an IF:


• In lines 8 and 9, we initialized two variables with their corresponding values
• Line 11, we checked the value of variable “b” if it is between 0 and 3 exclusively.

If it is:
o In line 12, we change the value of variable “a”.
o In line 13, we place the variable “b” in a switch statement which multiplies the variable
“a” with a multiplier (line 15 and 18) depending on the value of variable “b”.

If it is not:
o In line 21, we multiple the variable “a” with 4 and store it back to variable “a”.

• In line 25, we finally display the value of variable “a”


• In lines 30 to 32, we conclude our application.

Noticed how the of variable “a” is again dependent on the of variable “b”? In this example, we forced
the value of variable “b” to be either 1 or 2 before we proceed to the SWITCH statement. Hence, we did
not need to add a DEFAULT statement.

In choosing which approach will be used, consider the number of paths that the code will go through
before finalizing your approach. This helps you make a more optimized application resulting to a more
efficient processing.

MODULE5
In the previous module, we discussed about code blocks and how variables are affected by code blocks.
In addition, we covered the two conditionals in C++ and differentiated them, namely:
1. IF Statements
a. If(...) { }
b. If (…) { } else { }
c. If (...) else if(...) { } else { }
2. SWITCH
a. switch(...) {case…: break; default: …;}
3. Nested Conditionals

Lastly, we explored a sample problem wherein we dissected several possibilities when using conditionals
in C++.

Introduction to Looping
Looping in C++ is a means to repeat a series of statements based on the provided condition. One pass in
the loop is called an iteration. Usually, a looping statement undergoes several iterations.

Phases of a Looping Statement


Like any other statements of a programming language, looping is also composed of several components.
These components build up the phases that a looping statement need to undergo internally. There are
four (4) phases of any looping statement in any programming language. These are:
a. Initialization
b. Condition
ITE6102
COMPUTER PROGRAMMING

c. Body
d. Increment/Decrement

Initialization
the phase in looping statements where a variable called counter is set an initial value. Note that
declaration of the counter can occur of the looping statement, hence there is no need to
prioritize declaration as part of the first phase. The counter manages the flow of the loop.
Usually, each iteration relies on the value of the counter, similar as how arrays are utilized in
looping statements. A typical initialization of a counter is set to 0. However, there are cases
wherein the counter is initialized with the actual number of iterations needed for the loop.
This setup is upon the discretion of the developer or as needed in the identified solution.

Condition
the phase in looping statements where an expression is evaluated which dictates whether the
loop should stop or continue. The counter is usually the basis of this phase, however that is not
always the case. The condition always occurs within the parentheses of the loop.

Body
the phase in looping statements where the statements inside the loop are executed. These are
simply the within the code block of the looping statement. The statements within the body
differ depending on the discretion of the developer.

Increment/Decrement
where the counter is incremented or decremented. Increment means a variable is added by a
certain constant. Decrement, the counterpart of increment, means a variable is subtracted by a
certain constant. This constant is typically 1. Depending on the chosen looping statement, the
Increment/Decrement can occur within the body.

Looping Statements in C++


C++ is armed with three (3) distinct looping statements which differ mainly on how the condition is
evaluated, and when the condition is evaluated. The looping in C++ are:
a. While Loop
b. For Loop
c. Do-While Loop

While Loop
a looping statement in C++ where the condition is evaluated right before the body is executed.
The initialization phase does not occur within the looping statement, or the parentheses of the
statement. The increment/decrement happens at the end of the body.
ITE6102
COMPUTER PROGRAMMING

Figure 1. Statement

Figure 1 shows the syntax of the WHILE statement. Notice that the initialization phase occurred at line 8,
outside of the actual looping statement. The condition phase is placed within the parentheses of the
WHILE statement at line 10. The body is from line 11 to 12. Lastly, notice that the increment/decrement
phase is located within the body at line 12.

Let us understand the flow of the source code.


1. At line 8, a counter i is initialized with a constant zero (0).
2. At line 10, the actual WHILE statement is used. Within the statement is the condition that
whether the counter i is still less than the constant nine (9).
3. At line 11, the first line of the body, a “#.) Hello World” string is displayed with an ending line.
4. At line 12, the counter i is incremented with the constant one (1).

If we follow the program flow, the WHILE statement will display “Hello World” prepended with the value
of the counter i + 1. If we try to understand the condition within the WHILE statement, the iterations will
end when the counter i reaches the value of 9. Hence, the “Hello World” line will be displayed 9 times.

If you did not get why there will be 9 lines of “Hello World” displayed, try counting up to before 9 (which
is 8). Remember to count from 0.

Essentially, Figure 1 simply display the line “Hello World” 10 times.

It is essential to simulate first the source code prior execution when using WHILE statements since it can
introduce a non-terminating iteration. Simply put, the loop will continue forever. This scenario will
continually consume the computer's resources which can cause the operating system to malfunction and
the computer to shutdown unintendedly.
ITE6102
COMPUTER PROGRAMMING

For Loop
For Loop is the looping statement in C++ where the initialization, condition and increment/decrement
phases occur within the parentheses of the statement. Only the body is separated from the actual FOR
statement. Compared to WHILE statements, FOR statements is range-based. This means that the
counter is essentially the blood and life of this looping statement.

Figure 2. FOR Statement

Let us look at the syntax and structure of a FOR statement in Figure 2. This example uses the same logic
and flow like our WHILE statement in Figure 1. The only difference is that we used FOR rather than
WHILE statement.

Dissecting the FOR statement in this example, we will have:


1. In line 8, the actual FOR statement is used together with the initialization of the counter i to a
constant 0, the condition which checks the value of the counter and the increment/decrement.
2. In line 9, the body of the FOR statement where the string "Hello World" is displayed.

While the WHILE statement seems a straightforward approach, FOR statement is otherwise. The flow
when the initialization, condition and increment/decrement phase occur is unclear if you simply look at
the structure.

The first thing the FOR statement does is it executes the initialization phase. This occurs only once,
when the FOR statement is called. Next, the condition is evaluated. When the condition returns false,
the body is executed. After which, the increment/decrement is executed. Here, one iteration is
completed. The condition is again evaluated and when it returned false, the body is again executed. The
cycle repeats until the condition evaluates to true.
ITE6102
COMPUTER PROGRAMMING

As you have now understood, the cycle is almost similar to WHILE statement. The only main difference
is when the increment/decrement is executed. In the WHILE statement, the increment/decrement can
occur before the other statements of the body; while in FOR statement, the increment/decrement
always occur after the of the body.

Though a rare occurrence, you can use more than one counter in FOR statement. The counters are
separated by a comma. The same applies to the increment/decrement. Try experimenting!

Do While Statements
The DO WHILE statement is closely similar to the WHILE statement. They only differ when the condition
is evaluated and when the body is executed. Let us look at an implementation of the DO WHILE
statement.

Figure 3. DO-WHILE Statement

Similar to the WHILE statement the initialization occurred outside of the actual looping statement.
Notice that the body of the loop is located on top of the condition. From the structure itself, we can
easily notice that even during execution, the statements within the body are executed first After which
the condition is evaluated, checking whether to continue the loop or stop it all together.

What does this suggest? In the above example, we cannot easily distinguish the effects of this kind of
approach. However, if we change the value of our counter i to something greater or equal to the
constant 9, there we will notice the big difference. Both in WHILE and FOR, the body will not be
executed since the condition is evaluated first which evaluated to true. But in DO WHILE, the body will
be executed regardless if the condition evaluates to true later on. By the time the condition is evaluated,
the counter i has already been incremented/decremented.
ITE6102
COMPUTER PROGRAMMING

Controlling Loops
Since the start of the module, when dealing with looping statements, everything has been linear and
straightforward. However, this is not always the case when we implement our solutions. In C++, we have
two controlling statements which cm change the flow of loops at any part of the iteration. These are the
BREAK and CONTINUE statements

The BREAK statements terminate the execution of the entire loop that it is encased. This is placed
anywhere within the body of the loop. Any statements found after the BREAK statement, should the
BREAK statement be executed, will not be executed.

The CONTINUE statements terminate the execution of the current iteration. What it does is force the
loop to skip the rest of the statements and proceed to the condition evaluation right away.

MODULE6
In the previous module, we dismissed mainly ab out what looping and iterations are. We also identified
the four (4) phases of a looping statement, namely:
a. Initialization
b. Condition
c. Body
d. Increment/ Decrement

In addition, we identified the different looping statements in C++, namely:


a. WHILE Statement
b. FOR Statement
c. DO WHILE Statement

Lastly, we discussed how the four (4) phases of looping are arranged in the looping statements of C++.

Variables in Dimensions
Since Week 4, we have been variable sin the conventional way. We are only dealing with them in one
dimension where one variable can only store one value. However, that is not the only way we can
manage the data stored in the computer.

The First Dimension


A quick recap about variables, when the computer learns that a variable was declared, it allocates
several spaces in the RAM for the declared variable. The number of spaces that will be allocated will
depend on the data type of the variable.

Data Type Allocated Size


Int 32 bits
Short 16 bits
Long 64 bits
Bool 1 bit
Float 32 bits (floating point)
Double 64 bits (floating point)
Char 8 bits
ITE6102
COMPUTER PROGRAMMING

If we follow the allocated sizes per data type, int for example, the computer will allocate 32 bits of space
for one integer variable. Those bits are located adjacent each other. Think of it as a train, one car is
adjacent to one another as one C 1) bit of the thirty-two C 32) bits integer is adjacent to one another,
internally speaking.

The same thing is applied to characters. One-character variable occupies eight (8) bits of space in the
RAM. How about strings since we talked about a string as a series of characters? In this case, string is an
example of an array. A string is a series of characters, wherein, a string can be composed of two
characters in one declaration such as this: char jai[2] = "86";

The Other Dimensions


An army is variable that can contain more than one of similar data types. Arrays are bounded still by the
data type they are declared. For example, if we declare an array of characters, the values that it stores
are all characters. Assigning non-character value in the said array would result to exceptions or errors.
An exception is a programming language- or developer-defined error that is the result of inappropriate
actions committed unexpectedly.

The syntax of declaring an array is: dataType variab1eName[size]; The dataType in the syntax is similar
to how we declare variables. It can be int, short, long, or any of the remaining data types. The
variabieName is our typical alias we give the variable to reference in the future. Lastly, the size is a non-
zero integer which dictates the maximum number of values the array can store.

In this example of char jai[2];, we are declaring an array of character type that store up to two (2) values
(characters). Take note that one character is eight (8) bits in size, therefore when the computer
recognizes that this array is declared, the computer will allocate sixteen (16) bits of size. Similar to our
example of the train, think of a variable as one cart. Now, in that example, the array of two (2)
characters are two adjacent carts. If we declared char postalCode[4];, we are declaring a maximum of
four (4) values for the character; hence, we have four (4) adjacent carts.

bitsOf1DArray = bitsOfDataType * sizeOfArray


Figure 1. Formula of the Allocated Size of 1D Array

This analogy is important to recognize the internal workings of the computer. For example, if we declare
two arrays char jai [2], postalCode[4]; , the computer will allocate two separate trains, one with two
carts and another with four carts. As to where exactly in the RAM those two arrays would be allocated
mainly depends on the computer.

There is a way to get exactly the address used by the computer to reference the arrays, and by
extension, the variables as well.

Up until now, we are only talking about one-dimension (1D) arrays. But the computer is powerful
enough to allow multiple-dimension arrays. Let us take a two- dimension (2D) array. When we compare
a one-dimension array to a train, we can think of a two-dimension array as a table. For example char
matrix [5] [5];, here we have a five-by-five array. In relation to a table, we have a table with five rows
and five columns. Similar to the rest of the examples, the said array can only contain character values.
ITE6102
COMPUTER PROGRAMMING

A limitation to this is that each row has exactly the same number of columns. Row 0 has five columns;
row 1 has five columns; until row 4 which has five columns as well. Notice that I started my counting
using the number zero (0). When we call the first cart using the variable name of the array, we use the
index 0. An index is an integer reference used to indicate which element of the array is being accessed.
An element is a value of the array. If we call matrix[0][0], we are calling the first column of the
first row. If we call matrix[0][1],we are calling the second column of the first row. The reason behind this
approach of calling the values in an array is because of how the computer interprets the call. For
example, remember our train example with a certain number of carts? To call the second cart, we use
index 1 since we are calling the value 1 element away from the first cart. If we use index 2, we are calling
the value 2 elements away from the first cart. If we use index 0, we are calling the value 0 element away
from the first cart, hence the first cart itself.

bitsOf2DArray = bitsOfDataType * rowsOfArray * columnsOfArray


Figure 2. Formula of the Allocated Size of 2D Array

It is possible to create three-dimension, four-dimension arrays but representing them in a real-world


application becomes tedious like a three-dimension array is a cube and a four-dimension array is like a
cube with the factor of time per se. In addition, creating these kinds of arrays are computationally
expensive and they consumer resources which grows exponentially.

bitof3DArray = bitsOfDataType * lengthofArray * widthOfArray * heightOfArray


Figure 3. Formula of the Allocated Size of 3DArray

bitof4DArray = bitsOfDataType * size1 * size2 * size3 * size4


Figure 4. Formula of the Allocated Size of 3DArray

Never use more than two-dimensional array since not only they are computationally and resource-
expensive, but also are hard to maintain code-wise. In addition, referencing those kinds of array are
erroneous. Should the need to use more than two-dimensional arrays arise, rethink the identified
solution. There is always better option rather than using more than two-dimensional arrays. The factor
to weigh in here is the approach used by the solution.

Arrays in C++
Arrays in C++ follow the general descriptions of the arrays as discussed in the previous topics, syntax
data-wise. Here are some applications of arrays that will be used throughout this course:

Declaring Arrays
When declaring an array, we use the syntax:
dataType variableName[size];
Figure 5. Declaring a 1DArray

dataType variableName[rowSize] [columnSize];


Figure 6. Declaring a 2DArray

The same syntax used in the previous topics shown in Figure 5 and 6. Declaring arrays are similar to how
we declare variables in C++ with only the digit differences in the size part. In array, we explicitly declare
the size of the array. C++ does not allow array of dynamic sizes.
ITE6102
COMPUTER PROGRAMMING

Assigning Values to Arrays


We assign values to the array as follows:

variableName [index] = value;


Figure 7. Assigning a Value to a 1DArray by Element

variableName [index1][index2] = value;


Figure 8. Assigning a Value to a 2DArray by Element

The syntax for assigning values to arrays by element is shown in figures 7 and 8. We can also assign the
multiple values of the array in one line as follows:
variableName = { value 1, value 2, .. valueN };
Figure 9. Assigning All Values to a 1D Array

variable Name [index] = { value 1, value 2, … valueN };


Figure 10. Assigning One-row Values to a 2DArray

variableName = { { value01, value02, … value0N }, { value11, value12, value1N }, … { valueN1, valueN2, …


valueN } };
Figure 11. Assigning All Values to a 2DArray

The syntax to assign multiple values for 1D array is shown in Figure 9. If we have int id [5] array, then we
assign values to it using one line by doing id = { 9765, 1214, 9678, 23, 78 };

The syntax to assign multiple values for 2D array equivalent to one row is shown in Figure 10. If we have
int cube [5][5] array, then we assign values to row 0 of it in one line by doing cube [0] = { 9765, 1214,
9678, 23, 78 };

The syntax to assign multiple values for 2D array equivalent is shown in Figure 11. If we have int idx
[3][2] array, then we assign values to it using one line by doing idx = { { 8, 9 }, {2, 90}, {100, 121} };

Referencing Arrays
We call the stored values in the array as follows:
std::cout << variableName[index];
Figure 12. Referencing an Element of a 1DArray

std:: cout << variableName [index1][index2];


Figure 13. Referencing an Element of a 2DArray

The syntax to display the values of an array is shown in Figures 12 and 13. We call the elements of the
array similar to how we assign values to the array. They only differ in the presence of the assignment
syntax - value. In referencing the array, we do not use the assignment syntax as shown in Figure 12 and
13.

Arrays in Action
In this section, we will dissect several examples of how arrays are used in actual C++ applications.
ITE6102
COMPUTER PROGRAMMING

Displaying Values of an Array


To start off, we will work on a problem about assigning values to an array and displaying them back to
the user afterward. Figure 14 details the problem-at-hand.

Write a program that accepts five (5) integers from the user and display them back in one line.
Figure 14. Problem Statement 1

Let us dissect first the problem. We have only two technical work items for Problem 1.
a. To accept five (5) integers from the user
b. To display the five (5) numbers in one line

Is the problem simple enough? Figure 14 shows us a version of the solution for Problem 1.

Figure 15. Source Code for Problem 1

The solution is pretty much straightforward approach. We start with reserving space for our array of
integers which contains five elements. By this time, our application already has consumed 32 bits * 5
elements = 160 bits. Next, we used FOR loop to get the user input. We specified the condition to be until
five (5 inputs. Lastly, we display the output using cout and consecutive streams of string formatting.
ITE6102
COMPUTER PROGRAMMING

Sorting Values of an Array


For our last example of using arrays in C++, we will work with sorting problems. Sorting problems are
problems that involve arranging the values of a given array in a specific arrangement. Usually, the
arrangement is ascending for numerical values, and alphabetically for textual values.

Figure 16. Problem 2 Write a program that accepts five (5) integers from the user, sort in ascending
order and display the sorted array in one line.

Let us dissect first the problem. In this problem, we have three technical work items:
a. To accept five (5) integers from the user
b. To sort the five (5) integers in ascending order
c. To display the five (5) sorted in one line.

We start again with reserving space for


our array of integers which contains five
(5) elements. Again, by this time, we
consumed 160 bits of space. Next, we
get the user input using FOR loop. The
sorting snippet is harder though. We
used nested FOR loops. The outer FOR
loop simply iterates through five (5)
user inputs. The inner FOR loop iterate
to the next user inputs past the
currently selected of the outer loop.

To make this clearer, let us take an


example of int [5] { 1, 9, 4, 2, 0 }. The
outer FOR loop will pass through 1, then
9 and so on until 0. The inner FOR loop
will pass through 9 and 4 until 0 if the
outer FOR loop is currently at 1. If the
outer FOR loops is not at 9, the inner
FOR loop will pass through 4 and 2 until
0.

Now, inside the inner FOR loop, we have


a conditional which checks if the
element selected by the outer FOR loop
is greater than the element selected by
the inner FOR loop. This is configured
like this since we are arranging the
Figure 16. Source Code for Problem 2.

elements ascendingly. Hence, we are checking if the elements in the left is larger in value than the ones
in the right. And if it is the case, interchange the two.
ITE6102
COMPUTER PROGRAMMING

In order to interchange the two elements, we used a separate variable to temporarily store the value of
the element selected by the outer FOR loop n[i] (left side). Next, we replaced the value of n[i]with the
element selected by the inner FOR loop n[t] (right side). Lastly, we assign the value in the temporary
variable to out n[t].

By the time the outer FOR loop completes, we will have n[0] =< n[1] =< n[2] = n[3] = n[4]. In example of
int [5] { 1, 9, 4, 2, 0 }, we will have int [5] { 0, 1, 2, 4, 9 }.

Lastly, we display the sorted integers to the user.

MODULE7
In the previous module, we discussed mainly about arrays. We discussed how the computer allocates
the appropriate space an application needs to perform its tasks. We also identified the syntax of an
array, composed by:
a. data Type
b. variableName, and
c. size.

We also discussed the different dimensions for the array, namely:


a. one-dimensional array
b. two-dimensional array
c. three-dimensional array, and so on.

Lastly, we were able to roughly compute the necessary space needed for the application to use its
declared variables and arrays.

Introduction to Functions/ Procedures


Code blocks are generally designed to be written inside the int main ( ) code block. This way, we look at
our code sequentially, that means we never left int main ( ) code block. This is the time to introduce
functions. Functions are a separate code block which performs one specific task. These separate code
blocks can accept inputs from the other code blocks. In addition, they can also return back values which
can be a result of the actions performed within the function.

We are all very familiar with the most famous function in the entire C++, the code block. The function, as
we have mentioned several times throughout the course, is the entry point of any C++ application. It is
here where we place the entire logic of our application. Like the name suggests, it is the main function
of the entire C++.

Components of Functions
A function is composed of several components which are similar to different programming languages.
These components build the fundamentals of a function which are necessary to completely differentiate
and define the role of a function from the rest of the other code blocks. Also, these components build
up the function's properties and capabilities which are exploited not only by the developer of the
application, but also other developers who uses several snippets of the source code. These components
are:
a. return type
b. function name
ITE6102
COMPUTER PROGRAMMING

c. parameters
d. body of the function

The return type is the data type which the function shall return as its final execution. The return type
can be any of the defined data types discussed throughout the as found in Table 1.

Return Type Description


Int Integer type
Short Short Integer Type
Long Long Integer Type
Bool Boolean Type
Float Single Floating-Point Type
Double Double Floating-Point Type
Char Character Type
Void No Return Type
Table 1. Return Types

Table 1 covers the fundamental data types in C++ with the addition of the return type. The
return type simply tells the application that the function shall not return any data.

You can modify the int main() function to have a void return type. Simply change the int return type to a
void return type, and remove the return statement within the new void main ( ) function.

The function name is the alias which will be used to as reference to the function. It is similar to variable
names. The only difference is the presence of the parentheses after the function name.

The parameter is the component of a function which enumerates the input values of the function. The
parameter is placed inside the parentheses of the function, right after the function name. The syntax for
the parameter is dataType variableName. A function can support more than one parameter. Should that
be the case, the parameters inside the parentheses are delimited by a comma.

The body of the function is the group of statements within the code block of the function. Regardless of
the design of the function, if the return type is not void, the last execution statement should be
return value, return expression.

Functions are also called Procedures.

Variations of Functions/Procedures
Functions can be arranged depending on the need of it and its function. C++ does not discriminate the
use of functions. Hence, any function can be defined any number of times.
ITE6102
COMPUTER PROGRAMMING

Void Function without Parameter

Figure 1. Void Function without Parameter

Figure 1 shows a source code where a void function printHelloWorld() is defined. Also notice that our
defined function is placed before the main ( ) function. The reason behind this approach is to let the
function be defined prior it is called. Let us say that the main ( ) came before our printHelloWorld( )
function. By the time our printHelloWorld( ) function is called inside the main ( ) function, our
printHelloWorld( ) function is called inside the main () function, our function is yet to be defined. Hence,
the main function will throw an exception stating that the printHelloWorld( ) is not defined.

Void Function with Parameters

Figure 2. Void Function with Parameter


ITE6102
COMPUTER PROGRAMMING

Figure 2 shows a source code where a void function printSum ( ) is defined with two parameters; two
integers a and b. Notice that within the printSum ( ) function, we simply displayed a text stating that we
are adding the two integers in the parameter. We called our printSum ( ) function within the main ( )
function and we passed the values 91 for parameter a and 23 for parameter b.

When passing variables into the parameters and not constant values, the variables pass their values and
not the variables themselves. The implication of this is the immutability of the original variables Hence,
after the original variables were passed, their values even when changed inside another function will
never be affected.

Int Function with Parameter

Figure 3. Int Function with Parameter

Figure 3 shows a source code where an int function is defined with two parameters; two integers a and
b. This time, we added a return type of int. Hence, the function must return an integer value back to
wherever it is called. The only statement within the sum ( ) function is a return statement which returns
the sum between the two integer parameters. In addition, inside the main ( ) function, we called our
sum( ) function as a supplement to our cout stream. Hence, we displayed right away the value returned
by the sum( ) function.
ITE6102
COMPUTER PROGRAMMING

Int Function without Parameter

Figure 4. Int Function without Parameter

Figure 4 shows a source code where an int function get FaveNumber( ) is defined with no parameter.
The function simply returns a constant back to whatever called it. In this case, it was called main ( )
function. However, in this case, the value returned by the getFaveNumber( ) function is stored to an
integer n inside the function.

MODULE8
In the previous module, we mainly discussed about functions. We discovered that the int main( ) code
block is a function. We identified the components of a function, namely:
a. Return type
b. Function name
c. Parameters
d. Body of the function

In addition, we enumerated the possible return types of a function as follow


a. Int
b. Short
c. Long
d. Bool
e. Float
f. Double
ITE6102
COMPUTER PROGRAMMING

g. Void
Lastly, we also covered several variations of functions, namely:
a. Void function without parameter
b. Void function with parameters
c. Int function with parameters
d. Int function without parameter

Introduction to Object-Oriented Programming


So far, the code blocks that we covered are centered in one thing and one thing only - the logic of our
application. We never diverted from that perspective of writing other things aside from the main logic
that our application needs to implement. However, this time, we will divert from mainly developing the
logic of our application. We will also develop entire codes to supplement the logic of our application.

Object-oriented programming is a programming paradigm which is centered in the use of objects.


Objects are representations of tangible and intangible materials that possess some level of
information. These objects can be anything from day to day materials we use to classification like the
congress. The only thing that limits them is the information that they should possess for us to
implement afterwards through programming.

Advent of Object-Oriented Programming


The practice of Object-Oriented Programming came as early as the year 1967. In that year, a
programming language Simula used features which we regard now as the fundamentals of Object-
Oriented Programming. The Simula is a programming language which specializes on simulations. It was
developed by Ole-Johan Dahl and Kristen Nygaard at Norwegian Computing Center in Oslo.

Alan Kay, working at the University of Utah, used the features present in Simula as inspiration to come
up with the idea of Object-Oriented Programming. This idea was completed at Xerox Parcwhen Alan Kay
lead a team after he transferred to Xerox Parc. At Xerox Parc in early 1970s, Object-Oriented
Programming as a programming paradigm was born.

Dynabook was the first personal computer that was created using Object-Oriented Programming.
Smalltalk was the Object-Oriented Programming Language built specifically for Dynabook. Since then,
the Object-Oriented Programming as a programming paradigm became popular. This inspired Bjorn
Stroup to integrate this paradigm to the most popular programming language of 1980s, the C language.

This gave birth to C++ as a programming language that sports Object-Oriented Programming.

Principles of Objects
To better understand the Object-Oriented Programming, you need to understand about the core of
Object-Oriented Programming - the objects. Objects are simply a representation of something that is
built by information.

Take a book of an example of an object. A book is represented by a title, author, year of publication and
publisher. A book is composed of pages. Pages can be thought of as another example of an object. A
page has page numbers, paragraphs, chapter tide, and subtopic titles.
ITE6102
COMPUTER PROGRAMMING

Let us choose a box as an object. A box has color, width, height and volume. In addition to that, we can
store other objects into a boxlike the book in our previous example.
The concept behind objects in Object-Oriented Programming is the same. An object has properties like
the color, width, height and volume of the box. An object has methods also which simply are just
functions that are centered within the object. A method can be anything like getHeight ( )
functions for our box object

Subsets of Object-Oriented Programming


Now that we have covered the fundamentals of Object-Oriented Programing, we need to focus on how
Object-Oriented Programming was implemented in C++. There are two C 2) basic categories under
Object-Oriented Programming. They are as follows:
a. Prototype-based
b. Class-based

Prototype-based
a subset of Object-Oriented Programming which focuses on reusability of the objects in terms
of extending initial state to a further defined state. In this design, a prototype is created by the
developer which will be copied and modified during run-time to represent the final state of the
object it truly represents. Think of it like a blank book. A developer creates a blank book in his
source code. The blank book contains all necessary information like the subject and a temporary
author, publisher and year of publication. During run-time, the blank book will be populated
with additional information through its methods. The information may come from user inputs or
the database.

Class-based
a subset of Object-Oriented Programming which focuses on abstract representation of the
objects. Abstract representation means there is no initial data present in the object definition.
In this design, the objects may share the same properties and methods. However, as compared
to Prototype-base, these objects are copies of their base object and not all throughout new
objects.

C++ adheres to a class-based Object-Oriented Programming.

Class-based C++
The idea behind a class-based C++ revolves around classes. Classes are an abstract representation of an
object. By themselves alone, classes are not objects. You can think of them as plans of the object that
have properties and methods. The properties do not have yet data.
ITE6102
COMPUTER PROGRAMMING

Figure 1. Class Structure

In Figure 1, we will explore the structure within a class. The provided source code is named
A short discussion of header files. C++ Header Files are separate files in C++ structure where extra codes
were placed to supplement the main application. Another use of header file is to reuse a huge range of
source codes for use of different applications. However, header files are not convertible to C++
applications.

Box Object in C++


Let us use our previous box object as an example in C++ classes.

Box Header File

Figure 2. Class Snippet of Box.h

Figure 2 shows a snippet of box. h which focuses on the class structure definition of the class. The
declaration started with the statement. Following that is the scope declaration public. There are three
(3) scope declarations, namely:
a. Public
b. Private
c. Protected

Scope Outside Inside Inheriting


Public Yes Yes Yes
Private No Yes No
Protected No Yes Yes
Table 1. Scopes in C++
ITE6102
COMPUTER PROGRAMMING

Table 1 summarizes the limitations of the scopes in C++. Public scope makes the properties and
methods under it accessible to anywhere within and outside the class. Private scope limits the access to
the properties and methods under it to only the class where they are defined. Protected scope limits the
access to the properties and methods under it to the class itself and to all classes that inherits it.

Figure 3. Properties and Methods of Box.h

Figure 3 shows the property and method declaration in our Boxclass. As you can notice, the properties
are simply variables within classes. They are declared similar to how variables are declared within the int
main ( ) function. We defined four (4) properties under the class, namely:
a. Char Color[]
b. int Length
c. int Width
d. int Height

In addition to the four (4) properties, we have two (2) functions within the Box class, namely:
a. constructor Box(int length, int width, int height)
b. int getVolume( )

A constructor is a special non-prerequisite function named as the class itself that is created to initialize
several properties or perform operations for the class upon declaration. A class can contain more than
one constructor provided no two (2) constructors has the same number of parameters.

And we have an int getVolume ( ) function. As you can notice, we did not have any code block under the
two functions. This is to promote code readability since we are only declaring the scope, function names
and parameters of the functions.

Figure 4. Body of the Constructor of Box.h

In Figure 4, we have the code block of our constructor. Notice how the constructor is structured using
Box: :Box(int length, int width, int height). We used the Box:: label to dictate that the Box(int length, int
width, int height) constructor is part of the Box class. The constructor simply assigns values to two (2)
properties of our class.

Figure 5. Body of the Constructor of Box.h


ITE6102
COMPUTER PROGRAMMING

Lastly, we have the body for our getVolume( ) function. Since we want to declare that the function is for
our Boxclass, we append Box : : - the class name followed by "::". Within the function, we returned the
product of our Length, Width and Height properties.

Int Main Function


Now that we have a working class in our box.h header file, we need to use it in our int main ( ) function.

Figure 6. Int Main Function

Notice that we have added a new library box. h to our main .cpp file. We used quotation marks to
indicate that our box. h library is located in the same file path as our main. cpp file. Had we used the
conventional greater than and less than symbols, the IDE and the compiler will search for the said library
in the default library of our C++ files, usually in our installation folders.

We declared a variable to have a Box data type. This is the same as if we are saying that the box variable
will use the Box class. In addition to that, since we added a constructor to our Box class, we called that
constructor during the same time we declared the box variable. We passed the constants 2, 3 and 4 as
our values to the parameter’s length, width and height, respectively.

Lastly, we called the getVolume( ) function of our Boxclass and displayed them back to the user. Notice
how we called the said function? We used the variable name followed by a period then the function
name, like box.getVolume( ) .
ITE6102
COMPUTER PROGRAMMING

MODULE9
In the previous module, we mainly discussed about the fundamentals of Object-Oriented Programming.
We also discussed about how Object-Oriented Programming came to be and how it penetrated the
world of Programming.

We also discussed about the meaning behind objects in Object-Oriented Programming and its
implications in development. We identified the subsets of Object-Oriented Programming, namely:
a. Prototype-based
b. Class-based

In addition, we discussed the class-based Object-Oriented Programming. We identified how C++


implemented class -based, through
a. Scopes
b. Properties
c. Constructors
d. Methods

We also identified the different scopes in C++, namely:


a. Public
b. Private
c. Protected

Lastly, we implanted Object-Oriented Programming in C++ through our Box Principles in Object-Oriented
Programming

Since the last module, we have talked about the world of Object-Oriented Programming. We covered
the essentials of Object-Oriented Programming which enabled you to write OOP Applications in C++.
However, the journey in the world of OOP does not stop there. There are four (4) principles behind OOP
that you need to learn and how it applies in your current knowledge. These principles form the core of
Object-Oriented Programming. They serve as the heart of OOP such that without them, OOP is just a
simple non-deterministic programming paradigm.

These four (4) principles are:


a. Encapsulation
b. Abstraction
c. Inheritance
d. Polymorphism

Note that these principles do not overlay the fundamentals of Object-Oriented programming discussed
in Module010. In fact, these principles both strengthens and extends those fundamentals to achieve a
complete programming paradigm.

Encapsulation
The principle of encapsulation is to hide the internal workings of your application. Encapsulation ensures
that only the necessary methods and properties are presented outside of the current class.
ITE6102
COMPUTER PROGRAMMING

This principle is initially enabled using scopes. Remember that there are three C 3) scopes in C++,
namely:
a. Public
b. Private
c. Protected

These scopes limit the visibility of the properties and methods from outside of the class and outside the
inheriting class.

In addition to scopes, we have accessors and mutators which limits the actions done in properties, and
by extension, including methods.

Accessors
An accessor is a method within the class that enables the retrieval of values hidden by scopes. For
example, if we hid the property int mylD under the scope, we cannot aa3ess that property from outside
of the class. To let the user, for example, retrieve the value stored in the int mylD property, we can use
an accessor.

Before tackling how to write accessors, we need to enumerate several characteristics of accessors that
must be observed. These characteristics are as follow:
a. Accessors are methods with the return type like the data type of the property.
b. Accessors are parameter-less methods.
c. Accessors should never assign to its referenced properties.
d. Accessors are prefixed with "get" in their function name.

As previously discussed, accessors are simply methods that enables the retrieval of values. Since an
accessor is a method for retrieving it must have a non-void return type. Its return type solely depends on
the data type of the hidden property it references. For example, if we have an int mylD under the
type of scope, its corresponding aa3essor should have the return

Subsequently, accessors are for retrieving values only. Its method declaration should never contain any
parameter since the value to be returned is not dependent on any other factors aside from the
referenced property itself. Adding parameters to accessors is unnecessary since the parameter should
never affect the value of the referenced property.

In addition, accessors should never assign to any of the properties, especially the referenced property.
Doing so defeats the purpose of accessors and might cause a call for integrity & checks. An integrity
check is a test conducted to the values of properties in classes throughout the execution of the
application. The idea behind integrity checks is to determine whether there exists a discrepancy
between the actual values of the property and the expected of the same property.

Lastly, accessors are prefixed with "get" in their function name to indicate that those methods are
indeed accessors. For example, if we are to write an accessor for our int mylD property, its equivalent
accessors should be get MyID() method.
ITE6102
COMPUTER PROGRAMMING

Implementing Accessors
We will look at a sample implementation of accessors in C++. For this example, we will be using a variant
of our previous Box example back at Module010. However, we will modify portions of the code to
accommodate changes to showcase the implementation of accessors in C++.

Figure 1. box.h Header File

Figure 1 shows a variant of our header file which has private properties. In this example, we moved all
the properties to private scope. Because of this, we cannot anymore call any of the properties (e.g. int
length) in our int main ( ) function. To provide read-only access to our private properties, we
implemented accessors.
ITE6102
COMPUTER PROGRAMMING

Figure 2. Class Snippet of box.h.

Figure 2 features a snippet of our box. h header file. In this snippet, we have added a new function
under our public scope, the int get Length() method. Notice that our int get Length()
method:
a. Has a return type of int similar to the data type of property,
b. Does not have any parameter, and
c. Is prefixed with "get" in the function name.

This so far complies with the characteristics of accessors. Now, let us look at the implementation of our
int getLength ( ) method.

Figure 3. Method Snippet of getLength( ) Method

As shown in Figure 3, our int getLength ( ) meth od simply returned back the value of our Length
property. There are no other operations done within the accessor. Hence, we fully completed the
characteristics of an accessor.

Mutators
Now that we have a method to retrieve from our hidden properties, we also have a way to assign values
to our hidden properties through mutators. A mutator is a method within the class that enables the
assignment of values to our properties hidden by scopes. For example, if we hid the string Color
under the private scope, we cannot anymore assign values to it directly. In this case, we will be using an
intermediary which will assign values to it- the mutator.

Like our accessors, mutators are bound to several characteristics which help define their purpose. These
characteristics must be keenly observed. These characteristics are:
a. Mutators have one parameter.
b. Mutators may or may not return the final assigned.
ITE6102
COMPUTER PROGRAMMING

c. Mutators are prefixed with "set” in their function name.

The main purpose of our mutator is to store values to our hidden properties, and that only. Therefore,
we set only one parameter - the processed or unprocessed value we will assign to the property.
Processed values are values that have been through several operations which changed the original value
to the current value. Unprocessed values are values which have yet to be modified.

To better understand the difference between processed and unprocessed values, we need to look at an
example. For example, I have a string value of "0100" and I want to assign that value to an int variable.
As of now, the value is still unprocessed since it has not yet been through any operation. Now, when we
assign this value to the variable, since the variable is of int data type, I need to convert the value to int.
The converted value then becomes our processed value.

Converting a value from one data type to a different data type is called "casting".

In addition, the mutator may or may not return the assigned value. This solely depends on the
developer’s discretion. However, it is advised to return the value if and only if there were some
operations conducted before the value is assigned to the property. In our previous example of a string
to be assigned to an int variable, since there will be conversion of data type about to take place, the
resulting int value should be returned. If the value will be assigned to the property directly without any
conversion or processing, then there is no need to return the value.

Lastly, mutators follow a naming convention to affix "see" in their function name. This is to convey the
use of the method without the need of documentations and comments.

Implementing Mutators
We looked at an implementation of aa3essors in our previous implementation. This time, we will look at
a sample implementation of mutators. For this example, we will use again our example from Module0 1
ITE6102
COMPUTER PROGRAMMING

Figure 4. box.h Header File 2

In Figure 4, we look at a variable of the class that implements the idea of both assessors and mutators.
Notice we have added a new method setColor (string) which, based on the naming convention used, will
assign a value to our string Color property hidden under private scope. Let us dissect this variant of our
Box class.

Figure 5. Class Snippet of box.h Header File 2

In Figure 5, we note that the string Color property is declared under private scope. This makes the
string Color property inaccessible outside of the class and by the inheriting class. Our added method
declaration is placed under the public scope. This is to ensure that our mutator is accessible anywhere
inside and outside of the class. We have placed one parameter under our mutator which is similar in
ITE6102
COMPUTER PROGRAMMING

data type with the concerned property string Color. Let us now look at the implementation of our
mutator.

Abstraction
Another principle in Object-Oriented Programming is the abstraction. Abstraction is the generalization
of classes and types to emphasize their functionality and interfaces over their implementation and
details. This principle work together with encapsulation since both focuses on making the internal
workings of the classes hidden from outside of the class. This is to make the class, and its properties and
methods to be self-descriptive of their tasks.

One of the ways to implement abstraction is using scopes. Remember that the scopes limit the way any
Other classes and functions interact with the properties and methods of a class. This way, in the
perspective of int main() for example, can only see the methods under the public scope. Inheriting
classes can see properties and methods both under the protected and public scopes.

Inheritance
Third of the four (4) principles in Object-Oriented Programming is the inheritance. Inheritance is the
means to extend the features and functionalities of existing classes and interfaces. In this principle,
there is a prerequisite of at least one existing class or interface.

An interface is a class in C++ which has methods that are virtual in nature. Virtual means that the
method is not implemented wherever inside of the class. In simpler terms, there is no code blocks under
those methods.

Figure 6. IBox interface

In Figure 6, we have implemented an interface called IBox. Notice that Ibox only has two (2) methods
and both of which are under the public scope. These two methods were defined as virtual methods
hence there were no implementations of those methods anywhere in the source code. In addition,
We have added = 0 after the method declaration to signify they are pure virtual.
ITE6102
COMPUTER PROGRAMMING

A pure virtual method is a method in the class that needs to be implemented by the inheriting class.
Since this class only contain virtual methods, this class is said to be an interface.

Figure 7. Box Class Inheriting IBox Interface

We have yet another version of our box example shown in Figure 7. In this Box class, we have inherited
the IBox interface we defined in Figure 6.

Notice how we implemented the inheritance through the class declaration class Box : public IBox. In this
line, we have inherited all statement properties and methods of the IBox interface.

Since the IBox interface contains two (2) pure virtual methods int getVolume( ) and string getColor( ),
we were required to implement the two methods inside our Box class.

Polymorphism
The last principle of Object-Oriented Programming that we will cover in this course is polymorph ism.
Polymorphism is the principle of Object-Oriented Programming that deals with different variations of
the same method. These function uses the same function name. They only differ in the combination of
data types used in their parameters.
ITE6102
COMPUTER PROGRAMMING

For example, we have the sum() function. This function shall accept two (2)
inputs in its parameter. Since we cannot force the use of the sum()function to be limited to integers
only, we need to polymorph the function.

In our sum() function example, we can create several variation of that same function. If Vie need to add
two integers, we can declare a int sum(int, int) function. If we need to add floats, we can declare a float
sum (float, float) function. And if we need to add three integers float sum (float, float), we can declare
int sum(int, int, int) and float sum(float, float, float) function.

Figure 8. Polymorphing the Sum Function

In Figure 8, we can see four (4) variations of the sum() function. We supported the combination of two
and three parameters for both int and float data types.

There are two (2) forms of polymorphism, the overriding and the overloading.

Overriding
the polymorph ism that occurs during compile time. Overridden methods are the common structure of
polymorphism. It considers the current form of the functions.
ITE6102
COMPUTER PROGRAMMING

In this type of polymorphism, we have the functions call upon the existing functions and overlap their
statements with another. This is common in inheriting classes wherein the parent class has an existing
method and the child class overrides that existing method to perform a different set of functions.

For example, we have a parent IBox interface from Figure 6. In that figure, IBox interface has two (2)
methods, string getColor() and int get Volume(). Then in Figure 7, the Box class inherited the IBox
interface. In doing so, Box class implemented the string getColor() and int getCVolume methods. In this
case, the trio functions of IBox was overridden by the functions of Box.

Overloading
The second form of polymorphism is overloading. Overloading occurs during the runtime. In this form of
polymorphism, the functions are given different parameters but share the same function name. These
functions usually reside within the same source code.

Figure 8 implements this form of polymorphism. Notice how sum()the functions are repeated and
structured differently from one another. The first variation is a sum () function for two integers. The
second variation is a sum() function for three integers. The second variation also called the first variation
of the function. The third variation is a sum() function for two floats. The last variation is like the second
variation; the only difference is that the last variation is for three floats.

MODULE10
In the previous module, we continued our discussion about Object-Oriented Programming. This time, we
focused on the four (4) principles of Object-Oriented Programming, namely:
a. Encapsulation
b. Abstraction
c. Inheritance
d. Polymorphism

In addition, we learned about the two (2) samples under Encapsulation,


namely
a. Assessors
b. Mutators

Lastly, we identified the two (2) forms of polymorphism, namely:


a. Overriding
b. Overloading

Introduction to Low-Level C++


Since the start of the course, we have explored the C++ programming language in its beauty as a high-
level programming language. We have altogether explored the conditionals, looping arrays, functions
and the Object-Oriented Programming schemes of C++.

Ideally, programming languages are categorized in terms of complexity by:


a. High -level Programming Languages
b. Low-level Programming Languages
c. Mid-level Programming Languages
ITE6102
COMPUTER PROGRAMMING

High-level Programming Languages


the easiest category of programming languages to work with. High-level Programming Languages are
programming languages that exhibits the strongest abstraction of its programming schema.

High-level programming languages enables developer to focus on the logic of the application they are
developing. They take away the obscure details of how to implement the technical of what they are
developing. In addition, they automatically manage the memory allocation part and resource disposal
aspects of the development.

High-level programming languages also limits the control of the developer over the operating system.
This is to fully manage the instructions that come and go to the operating systems instruction set. This
part of high -level programming languages is essential which allows the developer to construct their
logic without bothering with too much about how to manage overflowing memory and proper resource
disposal.

Low-level Programming Languages


the hardest to manage of all the categories of programming languages. Low-Programming Languages
are programming languages that exhibit the weakest abstraction of all the programming languages
aside from machine languages themselves.

Low-level programming languages also enables the developer to get into detail of how they like their
logic to be implemented. Low-level programming languages can give access to even the hardware
components of the computer and the inner workings of the operating system. They can manage and
manipulate the runtime tasks that the current running operating system is working on.

Low-level programming languages also lets the developer explore the world of embedded systems,
giving them access to even the smallest component in the environment. Developers are given direct
access to the memory of the computer, particularly the random-access memory. They can also
manipulate the values stored in other memory sectors. There exist the least limitations passed to low-
level programming languages.

Mid-level Programming Languages


the go-in-between of the other programming languages. Mid-level Programming Languages are
programming languages that exhibit strong abstraction and mid-range access to the memory and
operating system.

Mid-level programming languages showcase user-friendly implementations and structures. Majority of


the features available to low-level programming languages are hidden in the background and are
usually taken for granted. Some of the implementations are hidden from the user. In addition, some of
the tasks are designed by the programming language to be abstract.

C++ Programming Languages


The programming language designed by Bjarne Stroustrup in 1979 was initially proposed as a high-level
programming language. The inner workings of C++ are hidden from the developer through its vide range
of libraries and features. Even the conditionals and looping statements do not exhibit what will originally
be considered a low-level in detail. This is mainly because the developer is limited to the aa3ess and
conditions that are present when performing such executions.
ITE6102
COMPUTER PROGRAMMING

However, due to the advent of the recent high -level programming languages like lava, C# and Visual
Basic NET, C++ are also considered to be a low-level programming language. This is supported by some
level of access that C++ give the developers. C++ enables the developers to get in-detail the memory
sector of the computer. In addition, there are a lot of memory-specific features that only C++ has.

This is further supported by the fact that the original Cis, a low-level programming language. Since C++
is, by extension, an extended version of C with the support for Object-Oriented Programming.

Introduction to Pointers and References


Now that we have established the fact that C++ can be considered a low-level programming language,
we need to dwell on one of the infamous low-level capability of C++ - the pointers and references. These
features of C++, coupled with dynamic memory allocations, form the fundamental of C++
being a low-level programming language.

Pointers
special variables in C++ that "points" to a sector in the memory. These variables are used as
companions of the other variables. They extend the coverage of the variables to such a point that the
original variables are being accessed from different sections of the code without being recreated
and reassigned.

In this point, the concept behind pointers might not be too dear. For example, we set a value to an int
myID variable. If we create a pointer int *ptrID with the address of int myID, any changes we do to the
int myID variable also happens to the int *ptrID pointer. And any changes we do to the int *ptrID pointer
also happens to the int myID variable. This is in contrast with the usual workings of variables.

For example, if we assign to another variable int yourID the of int myID, then when changes occur to one
of them, that said change is only done to that specific variable. For instance, we assigned the constant 2
to int myID variable, then the value assigned to the int vourID variable will not change. And the same
thing happens vice-versa. The change is isolated.

Pointers create somewhat like a mirror image of the variable they are pointed to. Changes are shared
between the two. It is also possible to create multiple pointers pointing to the same variable.
ITE6102
COMPUTER PROGRAMMING

Figure 1. myID Variable and ptrID Pointer

As seen in Figure 1, we have declared a variable int myID and a pointer *ptrID. The pointer is then
assigned the value of the address of the variable. More on this later. We then displayed the values of
the int myID variable and the int *ptrID pointer. If we run this source code, the value of int myID variable
is 19 while the value of the int *ptrID pointer can be any address value like 0x071Ww1. To retrieve the
value of the variable our int *ptrID pointer is pointed to, we append an asterisk (*) to the pointer. In that
line, we will have the value of 19.

A pointer is then assigned with the address of the variable which is done by appending an ampersand
(&), the address of operator, before the variable name. The address of the variable is in the format
0xSSSSSS where an S is alphanumeric. As seen in Figure 2, remember though that the address of the
variable and pointer differs. The stored in the variable is the actual value whereas the value stored in the
pointer is the address of the variable it is pointing to.

References
We have used the address of (&) operator to retrieve the address of the variable. In addition to that,
we can also use the address of (&) operator like pointers. That is a reference. A reference is a special
variable which, like pointers, stores the address of a variable. The main difference is that the address
stays permanent, whereas pointers can change the variable where they point to.
ITE6102
COMPUTER PROGRAMMING

Like a pointer, changes done to the original variable where a reference was pointed to will also affect
the output of the reference. This is also vice-versa. Changes done to the value of the reference will
change the value of the variable it points to. Since this is the case, when we assign another variable to
the reference, what we are doing there is copying the value of the variable and storing it to the
reference and to the original variable the reference is pointing to.

Figure 3. Variables myId , yourId, and Reference refId

In Figure 3, we can observe the behavior of a reference. The application started with the declaration of
int myID and int yourID variables, and a reference int &refIF pointed at int myId . In the said figure, when
we displayed the values of the variables and reference, we will get 193612, 856891 and 193612
respectively.

Later, in the code, we changed the value of the reference int &refld followed by the changing of the
value of int yourld variable. If we display the values now, we will get 856891, 756231 and 856891 and
193612 respectively. Notice how the variable int myId and the reference int &refld changed their values;
however, was unaffected by the change of the value of variable int yourId.

Figure 3 demonstrates the behavior of references, especially when compared to pointers in C++.
ITE6102
COMPUTER PROGRAMMING

MODULE11
In the previous module, we identified the classifications of programming languages by complexity,
namely:
a. High-level Programming Languages
b. Low-level Programming Languages
c. Mid-level Programming Languages

We also identified several key aspects of C++ that made it a Low-level Programming Language, namely:
a. Pointers
b. References
c. Dynamic Memory Allocation

Lastly, we discussed the ideas behind pointers and references, and differentiated them through
examples.

Variables, Pointers and References


In the previous module, we covered using and references in variables. This time, we will go in depth with
how a pointer variable and a reference variable work We will discuss the differences between variables,
pointers and references when undergone through a cycle of operations commonly conducted
throughout an application's lifecycle. Table 1 enumerates the main differences between the behaviors
of variables, pointers and references.

Actions Variables/Arrays Pointers References


Declaration Variable name is not Variable name is Variable name is
preceded by an asterisk preceded with an preceded with an
(*) or ampersand (&). asterisk with an ampersand (&).
asterisk (*).
Data Type Variable is data type- Pointer is data type- Reference is data type-
agnostic agnostic. agnostic.
Initialization Variable may be Pointer may be Reference may be
initialized anywhere initialized anywhere initialized only during
during and after during and after declaration.
declaration. declaration.
Value stored Actual value assigned. Address of the variable. Address of the variable.
Variable reassignment Not applicable for Pointers change the Pointers cannot change
variables. variable it points to. the variable it points
to.
Assigning a Variable Variable copies the Pointers copy the value References copy the
value. of the variable and value of the variable
store it to the variable and store it to the
it originally points to. variable it originally
points to
Assigning a Value Variable copies the Pointer retrieves the References retrieve the
value. value and stores it to value and store it to
the variable it points variable it points to.
to.
ITE6102
COMPUTER PROGRAMMING

Retrieving the value Variable returns the Pointer returns the References return the
(Address of Operator) address it currently address it currently address of the variable
occupies in the occupies in the it points to.
memory. memory.
Table 1. Differences between Variables, Pointers, and References

Declaration
We staff off with the declaration of variables, pointers and references. Since we have been dealing with
variables since Module004, the behavior of variables when declaring them are not a surprise.

Variables
declared as is, the data type followed by the variable name. The variable name may start with several
underscores but must never start with a numerical value. Declaring them allocates a memory equivalent
to the maximum capacity of the data type declared with it.

Pointers
use asterisk (*) operand prior the variable name to signify that we are declaring a pointer, and not a
variable. The asterisk may come after the data type, in between of the data type and the variable name,
or before the variable name. Declaring a pointer allocates a memory still equivalent to the maximum
capacity of the data type declared with it.

References
use ampersand (&) operand prior the variable name to signify that we are declaring a reference, and not
anything else. Like pointers, the ampersand may come as suffix of the data type, in between the data
type and the variable name, or as prefix to the variable name. Like both variables and pointers,
references allocate the same amount of memory like the maximum capacity of their data type.

Data Type
Next, we cover the effects of the data types to the variables, pointers and references.

Variables, pointers and references are all data type-agnostic. They are dependent on the data type they
are declared with. They cannot change the data type after declaration, during compile time and during
runtime. In addition, they cannot accept any other value or variable having a different data type.
Necessary casting is needed for the variables, pointers and references to accept values and variables
belonging to different data types.

Initialization
Initialization is the phase where in a variable, pointer and reference are assigned their default or initial
value. Variables and pointers behave the same. References only from the two.

When initializing variables, the initialization can occur anywhere in the code as long as it is after the
variable declaration. Initialization can also occur at the same line with its declaration. Late initialization
is also allowed.

Pointers behave the same to variables in all regards. Initialization of pointers can occur after the pointer
declaration, or even during the same declaration line. Late initialization is also allowed.
ITE6102
COMPUTER PROGRAMMING

References differ from the two. Initialization should occur always in the same line as the reference
declaration. Reference does not any other initialization after the declaration stage. Should the reference
not be initialized during declaration, an error will be thrown during compile time. Similarly, late
initialization is not allowed.

Value Stored
Variables behave differently from pointers and references. Variables store the actual value it is
supposed to store. The memory allocated to it will hold the value stored to the variable and not
elsewhere.

Pointers and references behave similarly in this case. The value stored within the and references are the
address of the variables they are initialized with.

A special case happens when a value is attempted to be stored to a pointer without undergoing
initialization first. The pointer behaves in an unexpected manner and overwrites an unknown
indeterminate sector in the memory. It is safe to say that this corrupts that sector of the memory. This
does not happen to references since they require the declaration and initialization stages to occur within
the same line.

Variable Reassignment

Variable reassignment occurs when a variable is being assigned to a pointer or reference. The same
structure is followed like the initialization stage. The only difference is the location where the
assignment occurs. Variable reassignment occurs after the initialization stage.

Variables do not undergo variable reassignment simply because of how variables behave when assigned
another variable. This will be discussed in "Assigning a Variable".

Pointers undergo variable reassignment. In doing this kind of assignment, the pointer changes the
address it points to into the new variable it is being assigned. In this case, the connection between the
previous variable is lost whilst the previous variable's value is unaffected. A new connection is created
between the pointer and the reassigned variable.

References also do not undergo variable reassignment. This is because of its design. References can only
be assigned a variable once. Any attempt to assign a variable will return errors. Assigning variables as
values is a different scenario which will be discussed in "Assigning a Variable".

Assigning a Variable
Assigning a variable is like the next subtopic, "Assigning a Value". Assigning a variable means a variable is
used in the assignment operand.

Variables being assigned a variable takes a copy of the value of the second variable and stores it to the
variable. This way, the value of the second variable is preserved while the first variable disregards its
value and changes it with the value of the second variable. In this case, the first and second variable,
though now show the same values, do not mirror each other. This means that changing the value of the
variable does not affect the second variable's value, and changing the value of the second variable does
not affect the first variable's value.
ITE6102
COMPUTER PROGRAMMING

A different scenario occurs in pointers and references. Both pointers and references copy the value of
the variable being assigned and stores them to the variable they point to. This overwrites the existing
value of the variable they point to the new one. These while the pointers and references retain their
current value, the address of the variable they point to.

Assigning a Value
Assigning a value means a constant is being used in the assignment operand. In this case, the actual
value is being stored.

Variables directly stores the value to the memory they are allocated. They do not copy it anymore and
simply store them without undergoing various operations aside from data type checks. This is
considering the value is of the same data type as the variable. Should it not be the case, the value needs
to undergo casting.

Like variable, pointers and references checks the data type of the value being assigned. Should it be the
same as with their declared data types, the value is being redirected to the address they and store the
said value to that address.

This in turn updates the value stored to the variable they point to and overwrites any existing value.

Retrieving the Value using Method


Retrieving the value using standard method is the conventional method to retrieve the value. It does not
use any other symbols aside from the variable name itself.

Variables return a copy of the value it currently holds in its allocated memory. No other data is
returned during the retrieval. Immediately processing the retrieved value does not affect the stored
value in the variable unless the processed value is assigned back to the variable.

Pointers behave differently from variables. Pointers return the address of the variable it currently
points to. This address is the actual value stored within the pointer. Similarly, processing the retrieved
value does not affect the pointer and the variable it points to. This is unless otherwise turns to an
assignment operation

References behave half-variable and half-pointer when retrieving the value using the standard method.
References, like variables, return the value of the variable it points to. However, we know that the
reference's value is the address of the variable, like the pointer. Like both variable and pointer,
processing the retrieved value does not affect the stored value of the reference and the variable it
points to.

Retrieving the Value using the Dereferencing Operator


Retrieving the value using the * unary operator. The * unary operand stands for the dereferencing
operator. This operator returns the value of the variable a pointer is pointing to.

Both variables and references do not support the use of the dereferencing operator. Attempting or
even forcing the use of that operator results to an error during compile time.
ITE6102
COMPUTER PROGRAMMING

The dereferencing operator is only applicable to pointers. What this unary operator does to pointers is
it retrieves the value stored in the address pointed at by the pointer.

Retrieving the Value using the Address of Operator


Retrieving the value using the & unary operator. Stands for address of operator. This operator retrieves
the address of something in the memory.

What that something is depends solely on the kind of the variable, should it be a variable/array, pointer
or reference.

Using the address of operator in variables returns the address of the variable. This address is the logical
address where the computer allocated a space for the variable to use. Again, the size of the allocated
space depends on the data type of the variable.

Using the address of operator in pointers returns the address of the pointer. This address, like variables,
is the logical address where the computer allocated a space for the pointer to store the address of the
variable it points to. Because the address of operator returns the address of the pointer, the address
retrieved is different from the address retrieved from using the address of operator to the variable.

Using the address of operator in references returns the address of the variable it points to. This address,
like variables and pointers, is the logical address where the computer allocated a space for the reference
to store the address of the variable. Because the address returned by this operator is the address of the
variable, using this operator to both the reference and the variable it points to will result to the same
address. As for retrieving the actual address of the reference, it is not supported in C++.

Functions, Pointers and References


It is also possible to use pointers and references in functions, particularly in the return type and the
parameters. This is mainly because a function is just a separate code block that contains its own set of
statements which are focused on replicability.

Pointers in the Parameters, Body


To implement pointers-references relation in functions, we invoke some of our parameters to be a
pointer. This process is like how we declare variables as pointers. We simply append the Dereferencing
(*) operator to our parameter name. By doing this, we can now use those parameters like how we use
pointers.

This enables us to keep the values we assign to the parameters for use outside of the function. Like if we
want our value to throughout the application, we can simply invoke the parameters as a pointer.

Since we enabled some of our parameters to support pointers, we can now use that parameter like how
we use pointers. We can assign new values, increment the value, decrement the value or totally remove
the value. These small changes will affect the original variable passed into the parameter.

References in Function Call


Now that we enabled our function to support pointers, we need to call the function and supply the
necessary parameters to exploit this change. We do this by replacing our regular variables in the
parameter section of the function call to append the Address Of (&) operator to the variable.
ITE6102
COMPUTER PROGRAMMING

This lets the compiler know that we are asking the function to point the changes to the address of our
variable, and not just copy the value in our variable. This sleek move makes the changes be stored to the
original variable, and not be limited to the parameter variable only.
ITE6102
COMPUTER PROGRAMMING

GLOSSARY
Abacus simple non-electrical device used for calculating values using beads.

Abstraction a principle of Object-Oriented Programming which generalizes the


properties and methods of classes in such a way that the
implementation is hidden from outside the class.

Accessor a method of a class that returns the value of hidden properties.

Address (Variable) the logical address of a variable in the memory.

Address Of (Operator) a unary operator which retrieves the address of a variable.

Address Of (&) Operator an operator which retrieves an address in the memory.

Algorithm a systematic quantifiable methodology in Computer Science where


there is a finite set of feasible solutions to solve a specific problem or
to achieve a specific condition or series of conditions.

Anonymous (Variables) variables that are not declared and are not assigned a name.

Array a variable that can store more than one value of similar data types

Arrow (Flowchart) a line with one and only one arrow head pointing to the next symbol
in the process.

Binary Operator an operator that supports two variables, arrays, or references where
to perform a specific operation (e.g. addition operator)

Body (Phase) a phase in looping where the statements within the code block are
executed.

Booleans (Data Types) data types that are either true or false, but not both, in value.

Break Statement a statement that terminates the execution of the entire loop.

Case Statements part of a SWITCH statement which defines the constant where the
variable-under-parameter is being compared.

Casting converting a value of one data type to a different data type.

Casting a means to convert the value from one data type to another data
type.

Central Processing Unit (CPU) a processor that carries out the instructions of an application.
ITE6102
COMPUTER PROGRAMMING

Characters (Data Types) data types that are textual in nature. They represent only one
character of the text.

Class-based (OOP) a subset of Object-Oriented Programming that focuses on abstract


representation of objects which are defined during development and
run-time.

Client-side (scripts) scripts that run in the used s web browser which provides interactive
user experience.

Code Block a series of related statements that are enclosed within curly
brackets/braces.

Commit upload a file to a repository that serves as a final agreement that the
changes to be saved is final.

Compiled Programming programming languages that needs a third-party software to


Languages translate source codes to executables.

Compilers a programming language-specific light-weight application that


translates source codes to executables.

Concurrency (programming) a feature in programming languages which allows to run several tasks
simultaneously without any dependency in the number of
processors.
Condition (Phase) a phase in looping where an expression or series of expression are
evaluated which determines whether the loop should continue or
end.

Conditionals code blocks that are executed only when the specified conditions are
met.

Constructor (Class) a special function within classes that initializes several properties and
performs operations during class declaration.

Continue Statement a statement that terminates the execution of the current iteration.

Counter (Looping) a dedicated variable used in looping which manages the flow of the
current iteration.

Data Type a means to limit the types of to be stored in a variable.

dataType (Array) the data type to bind the array.

Data Type-Agnostic data type dependent; may not accept values or variables belonging to
other data types without undergoing casting.
ITE6102
COMPUTER PROGRAMMING

Decimal Precision allows values to contain decimal point and numbers at the right of
the decimal point.

Default Statements part of a SWITCH statement which defines an alternative execution


should all of the CASE statements fail.

Delimited means separated; as part of a format.

Dereferencing Operator an operator that retrieves the value of the variable a pointer is
pointing at.

Development act of writing building and deploying applications which may involve
more than one computer programming language.

Development Artifacts files of varying purposes that are used for Software Development.

Do While Statement a looping statement where the in initialization also occur outside of
the actual looping statement, but the body is executed before the
condition is evaluated.

Element (Array) a sector of the array that either contains value or not.

Else Statements part of an IF statement that presents an alternative execution should


all of the conditions under the IF and ELSE IF statements.

Else If Statements part of an IF statement that extends possibilities to cover other


scenarios not under the original IF.

Encapsulation a principle of Object-Oriented Programming which groups the


functionalities and statements of certain areas in a code block.

End Terminator (Flowchart) an “END”-labeled Terminator symbol in flowcharts that marks the
end of the entire flowchart

Exception a programming language- or developer-defined error.

Executables runnable application. Computer-readable file that performs a specific


set of read-only instructions.

Explicit (Variables) variables that are declared and are assigned a name.

Extensive Markup Language a specially crafted message digest to deliver data between to
(XML) different applications regardless of platform using Markup Language
(using user-defined markup tags like those used by HTML).

Finite has a limit or constraint.


ITE6102
COMPUTER PROGRAMMING

Flash drives a storage device that utilizes the use of flash memory to store
permanent data and information.

Floating Point a number that does include the use of a decimal points; they are
usually precise only to a specific number of decimal places.

Floating Point (Data Types) data types that are numerical in nature and do have decimal
precision.

Flowchart a visual aid showing a sequence of actions or operations with only


(Computer Programing) one entry and one exit.

For Statement a range-based looping statement.

Function a separate code block which performs one specific task, and can
accept inputs and return outputs back to a code block.

Global Variables variables that are declared outside of the “int main ( )” function that
are usable anywhere within the source code.

Graphics Processing Unit (GPU) a processor that enhances the capabilities of the central processing
unit through rendering graphical information.

Hard drives a storage device that utilizes the use of disks to store permanent data
and information.

Hardware an electrical component of any computer built with circuits.

Header Files a separate C++ file which contains supplementary codes for
applications.

High-level Programming a set of programming languages that exhibits the strongest


Languages abstraction and farthest memory and operating system control.

If Statements conditional that execute the statements within if a series of non-


constant conditions are met.

Increment/ Decrement (Phase) a phase in looping where the counter undergoes a linear change in
value by a constant.

Index (Array) an integer which dictates which element of the array is being
accessed.

Inheritance a principle of Object-Oriented Programming which extends the


features and functionalities of existing classes and interfaces.
ITE6102
COMPUTER PROGRAMMING

Initialization (Phase) a phase in looping where the counter variable is assigned its initial
value.

Implicit (Variables) variables that are not declared but are assigned a name.
Immutability a property which states that the value cannot be changed.

Integer a number that does not include the use of decimal points; commonly
referred to as “whole numbers”.

Integer Values (Values Types) data types that are numerical in nature and does not have decimal
precision.

Integrated Development a fully-integrated software that contains various features dedicated


Environment (IDE) to software development.

Integrity Check a validation conducted to verify the integrity of the values of


properties throughout the execution of the application.

Iteration one pass in a loop.

Internet of Things (IoT) a network of internet-connected devices, vehicles, establishments


and other embedded systems.
Input (devices) parts of a computer that takes data for the computer to process.

Iteration a series of repetitions wherein each set is usually provided with


different inputs compared to the previous sets.

JavaScript Object Notation a specially crafted light-weight message digest to deliver data
(JSON) between to different applications regardless of platform using
JavaScript notation (using curly brackets).

Local Variables variables that are declared inside a code block that are only usable
within the code block.

Looping a means in programming languages to repeat a series of statements


directed by the set conditions.

Low-level (Understanding) Understanding the technical aspects of a specific topic or focus point.

Low-level Programming a s et of programming languages that exhibit the weakest abstraction


Languages and closest memory and operating system control.

Low-level Solution a specific solution which presents all the detailed information and
processes involved within.

Native Microsoft a development paradigm for Windows wherein the entire process
Windows Application depends solely on the built-in libraries and utilities of Windows to
ITE6102
COMPUTER PROGRAMMING

(Development) develop Microsoft Applications.

Main (Function) a function which serves as the entry point of any C++ application.

Methods (Class) functions inside an object which is centered on the use of object.

Microcontroller a small credit card-sized programmable computer using integrated


circuits that has input and output pins for general-use.

Mid-level Programming a set of programming languages that exhibit strong abstraction and
Languages some memory and operating system control.

Mutator a method of a class that assigns value to hidden properties.

Object-Oriented Programming a programming paradigm centered in objects.

Objects (OOP) a digital representation of tangible and intangible objects.

Output (devices) parts of the computer that displays information to the users.
Overloading polymorph ism that happens during runtime.

Overriding polymorphism that happens during compile time.

Parameter a component of functions which enumerates the input values


that the function can process.

Platform any Personal Computer, Macintosh, Android Wear or other devices


where an application can run.

Polymorphism a principle of Object-Oriented Programming which allows multiple


variations and versions of the same function sharing the same name.

Pointers Special types of variables that store the address in the memory rather than
the actual value or constant wherein the address can change
depending on the assignment of another variable.

Port (of an application) a specialized version of an application designed for a specific


platform which originally not supported.

Porting act of rewriting existing working codes of a specific platform to


support other platforms which is not supported by the current codes.

Primitive (Data Types) data types that directly store the within them and are retrieved with
in their own parameters.

Private (Scope) a scope which makes properties and methods limited in access to
only within the class itself.
ITE6102
COMPUTER PROGRAMMING

Problem Solving systematic approach in searching for a solution to a specific problem.

Procedure see Function.

Process (devices) of the computer that performs calculations which then are presented
to the users as intellectual information.

Processed Value a value that has undergone a series of operations and modifications

Programming act of writing codes using a specific computer programming


language.

Projects Directory a directory located in the users Documents directory that will contain
all projects for the development process.

Properties (Class) fields inside an object which gives primary information centered on
the object.

Protected (Scope) a scope which makes properties and methods limited in access to
within the class itself and the inheriting classes.

Prototype-based (OOP) a subset of Object-Oriented Programming that focuses on objects


with initial states which are extended during run-time.

Pseudocode an English-like high-level description of the processes in Computer


Programming.

Pure Virtual (Method) a virtual method that must be implemented in the inheriting classes.

Public (Scope) a scope which makes properties and methods available for access
outside the class.

Referenced (Data Types) data types that references to different sectors in the memory to store
and retrieve Values stored in Referenced Data Types are not stored
and retrieved within the variable, but are stored and retrieved to
another address the computer implicitly assigned it.

Reference special type of variables that stores the address in the memory rather
than the actual value or constant wherein the address is permanent
and unchanging.

Repository a virtual online directory where source codes, configurations and


documentations are stored that typically allows defined to review
and download the contents.

Return Type a component of functions which dictates the data type of the
ITE6102
COMPUTER PROGRAMMING

value that the function will return as its final execution.

Scalar (Value) a single value (e.g. 1, 123, “a” or “abc”).

Scope defines the coverage and access of the properties and methods inside
a class.

Server-side (scripts) scripts that run in the hosting server which provides database
integration and heavy data crunching.

Single-threaded Flow a concept in flowcharting wherein there is only one allowed flow for
the sequence of processes.

Size (Array) a non-zero integer which dictates the maximum number of values
that the array will store.

Software any intangible computer file or group of files that performs tasks and
computations collectively.

Source Code a file containing human-readable program codes.


Snippet a part of the entire code

Sorting Problem a problem that involves arranging the elements of an array in a


specific order.

Start Terminator (Flowchart) a “START”-labeled Terminator symbol in flowcharts that marks the
start of the entire flowchart.

Storage (devices) parts of the computer that stores temporary and/or permanent
information.

String any number of characters enclosed by quotation marks that is


treated as a single value.

Strong-typed (Data Type) see Explicit Variables.

Switch Statements conditional that compares one specific variable against a set of
defined constants or values.

Technical Work Items a set of short keyword-driven phrases which summarizes the things
to consider in each problem.

Unary Operator an operator that only supports one variable, array, pointer or
reference where to perform an operation (e.g. assignment operator).

Unprocessed Value a value that is yet to undergo operations and modifications


ITE6102
COMPUTER PROGRAMMING

Utility-Centric t (Root) Directory a directory located in the root directory of the current operating
system that will contain all utilities and tools to be used for the
development process.

Variable a temporary storage of a scalar value.


a temporary storage of value.

VariableName (Array) the alias given to reference the array, similar to variables.

Variant (Data Type) a data type that does not restrict the kind of values stored to the
variables; data types that can store any type of values.

Virtual (Method) a method which does not have a body.

While Statement a looping statement where the initialization occurs outside of the
actual looping statement, and the condition is evaluated first before
the body is executed.

You might also like