CC 102 Chapter 1
CC 102 Chapter 1
CHAPTER
1
CC 102 Fundamentals of Programming
OVERVIEW OF
COMPUTER
AND PROGRAMMING
Part 1: Computer and
Programming Languages
1
09/10/2022
CHAPTER
1 Topic Outline
• Introduction
CC
HCI
102 Fundamentals
101 Human Computer
of Programming
Interaction 1
Programming Languages
1.1.1 Introduction
2
09/10/2022
History of Computer
Abacus
The first device known to carry out
calculations – addition and
subtraction.
History of Computer
Pascaline
It is a mechanical calculator capable
of performing addition and
subtraction.
3
09/10/2022
History of Computer
Step Reckoner
It is a device that was able to add,
subtract, multiply, and divide.
History of Computer
Jacquard Loom
It is a machine developed that used a
series of punch cards to control
weave operations.
4
09/10/2022
History of Computer
Difference Engine
It is an automatic mechanical
calculator designed to tabulate
polynomial functions.
History of Computer
Analytical Engine
It is a general-purpose, fully program-
controlled, automatic mechanical
digital computer.
5
09/10/2022
History of Computer
History of Computer
Mark I
It is the first computer-like machine; A
programmable, electromechanical
calculator.
6
09/10/2022
History of Computer
History of Computer
7
09/10/2022
8
09/10/2022
9
09/10/2022
10
09/10/2022
11
09/10/2022
C# Scala Groovy
2000, Microsoft 2003, Martin Odersky 2003, James Strachan,
Bob McWhirter
Go Swift
2009, Google 2014, Apple
12
09/10/2022
Computer System
• A computer is an electronic device capable of performing commands.
• There are three main classes of computers: (1) personal computer, (2)
workstation, and (3) mainframe.
• There are two main components of a computer system: hardware and software.
13
09/10/2022
14
09/10/2022
Analog Digital
Memory Stored in the form of wave signal Stored in the form of binary bit
15
09/10/2022
16
09/10/2022
• The most basic language of a computer, the machine language, provides program
instructions in bits. Early computers were programmed in machine language.
17
09/10/2022
• The next step toward making programming easier was to devise high-level
languages that were closer to natural languages, such as English, etc.
Compiler Interpreter
18
09/10/2022
19
09/10/2022
20
09/10/2022
CHAPTER
1
CC 102 Fundamentals of Programming
OVERVIEW OF
COMPUTER
AND PROGRAMMING
Part 2: Programming Tools
CHAPTER
1 Topic Outline
• Introduction
CC 102 Fundamentals of Programming
OVERVIEW OF •
•
Dev C++
CodeBlocks
COMPUTER •
•
CxxDroid/CppCode
Coding Rooms
AND PROGRAMMING
Part 2: Programming Tools
21
09/10/2022
22
09/10/2022
Step 1 First you must download the Dev C++ on your Windows machine. Visit
to Download Dev C++: http://www.bloodshed.net
Step 4 This package will download C++ .exe file for Windows that can be used
to install on Windows 7/8/XP/Vista/10.
23
09/10/2022
Step 5 You will direct to SourceForge website, and your C++ download will start
automatically.
Step 6 In this step, you can see different components of Dev C++ that will be
installed with this package. Just click on “next” button.
Step 7 In this step, by default, the destination folder is in C drive. You are free
to change this destination folder but make sure you have enough
memory. Click on “Install” button.
24
09/10/2022
Menu bar
Toolbars
Report pane
Code editor
Status bar
25
09/10/2022
Step 1 Visit codeblocks.org. Click Download from the menu, then click on
download the binary release.
Step 2 Go to your operating platform section (e.g., Windows XP / Vista / 7 / 8.x /
10), then download the installer with GCC Compiler, e.g., codeblocks-
17.12mingw-setup.exe or Click here to download.
Step 3 Double-click to run the downloaded installer and click Next on the pop-
up window. Now click on “I Agree” to accept the license agreement.
Step 4 On the new pop-up, don’t do anything, just click Next and then change
the installation directory if you want (default directory recommended).
Click Install.
26
09/10/2022
Step 5 Wait for a minute for installation to complete. A new pop-up asks you to
run Codeblocks. Click YES, and then it shows the compiler Codeblocks
detected. Click OK.
Step 6 Now we have installed Codeblocks on windows.
Step 7 We need to verify the Compiler and Debugger path (this step is
optional).
Step 8 Similarly, for debugger path: Settings >> Debugger >> GDB/CDB
debugger >> Default. In Executable, the path should be C:\Program
Files\codeblocks\MinGW\bin\gdb.exe or C:\MinGW\bin\gdb.exe if you
have installed MinGW compiler before installing Codeblocks.
27
09/10/2022
Menu bar
Toolbars
Management
Editor
Editor tab
Status bar
28
09/10/2022
Step 1 CxxDroid / CppCode – C++ compiler IDE for mobile development app
available on Play Store / App Store. So search and find it.
Step 2 Choose install option under the CxxDroid / CppCode – C++ compiler
IDE for mobile development logo, and enjoy!
29
09/10/2022
30
09/10/2022
Step 5 You will be asked to give your first name and last name. Answer
correctly then, click the “Finish” button.
Step 6 You will be redirected to the main page of the website called learner
dashboard.
Step 7 Go to the “Workspaces” tab.
Step 8 Create “+ New Workspace” using the following credentials:
Title: Code Block: Lastname, First Name, MI (Sample: CC102 IT1A:
Reyes, Joshua C.)
Code Language: C++ Next (Latest; CR2)
Enable Workspace V2: ON
31
09/10/2022
Step 12 You can create cpp files by clicking first the folder where you want to
save the file then click the (+) icon.
12.2 Once organized, you are now ready for the course. For further
instructions and tips on using the coding rooms, kindly wait for your
instructor to give them.
32
09/10/2022
33
09/10/2022
CHAPTER
1
CC 102 Fundamentals of Programming
OVERVIEW OF
COMPUTER
AND PROGRAMMING
Part 3: Problem Solving
CHAPTER
1 Topic Outline
• Basic Steps
CC 102in Problem Solving
Fundamentals of Programming
OVERVIEW OF •
•
Structured Programming
Flowchart
COMPUTER • Pseudocode
AND PROGRAMMING
Part 3: Problem Solving
34
09/10/2022
3.1.1 Introduction
Problem Definition
• Defining the problem involves understanding it and being able to state it.
Problem 1
Statement of the Problem Write a program to determine the sum of two numbers.
Definitive Statement of the Give the computer two numbers. It should be able to
Problem add the two numbers and give the result.
35
09/10/2022
Problem Definition
Problem 2
Statement of the Problem Write a program that will compute the area of a circle.
Problem Definition
Problem 2
Statement of the Problem Write a program that will compute the area of a circle.
Definitive Statement of the Give the computer the values of pi and radius. It should
Problem be able to square the radius then multiply by pi to get
the area of the circle.
36
09/10/2022
Problem Analysis
• Analyzing the problem involves identifying the nature, scope, input, output, and the
process.
Problem 1
Statement of the Problem Write a program to determine the sum of two numbers.
Definitive Statement of the Give the computer two numbers. It should be able to
Problem add the two numbers and give the result.
Nature Algebra
Scope Integer or whole numbers only
Problem Analysis
Problem 2
Statement of the Problem Write a program that will compute the area of a circle.
Definitive Statement of the Give the computer the values of pi and radius. It should
Problem be able to square the radius then multiply by pi to get
the area of the circle.
Nature
Scope
37
09/10/2022
Problem Analysis
Problem 2
Statement of the Problem Write a program that will compute the area of a circle.
Definitive Statement of the Give the computer the values of pi and radius. It should
Problem be able to square the radius then multiply by pi to get
the area of the circle.
Nature Geometry
Scope Fractions or decimals are accepted values. No negative
values for the radius should be accepted.
Problem Analysis
Problem 1
Statement of the Problem Write a program to determine the sum of two numbers.
Definitive Statement of the Give the computer two numbers. It should be able to
Problem add the two numbers and give the result.
Nature Algebra
Scope Integer or whole numbers only
Input Two (2) integer numbers
Output The sum of the two numbers
38
09/10/2022
Problem Analysis
Problem 2
Statement of the Problem Write a program that will compute the area of a circle.
Definitive Statement of the Give the computer the values of pi and radius. It should
Problem be able to square the radius then multiply by pi to get
the area of the circle.
Nature Geometry
Scope Fractions or decimals are accepted values. No negative
values for the radius should be accepted.
Input
Output
Problem Analysis
Problem 2
Statement of the Problem Write a program that will compute the area of a circle.
Definitive Statement of the Give the computer the values of pi and radius. It should
Problem be able to square the radius then multiply by pi to get
the area of the circle.
Nature Geometry
Scope Fractions or decimals are accepted values. No negative
values for the radius should be accepted.
Input The values of pi and radius
Output The area of the circle
39
09/10/2022
Problem Analysis
Problem 1
Statement of the Problem Write a program to determine the sum of two numbers.
Definitive Statement of the Give the computer two numbers. It should be able to
Problem add the two numbers and give the result.
Process Enter two numbers using the keyboard. The computer
must be able to reject fractions and decimal numbers.
The computer will then add the two numbers. The result
of the addition will be displayed on the computer
screen.
Problem Analysis
Problem 2
Statement of the Problem Write a program that will compute the area of a circle.
Definitive Statement of the Give the computer the values of pi and radius. It should
Problem be able to square the radius then multiply by pi to get
the area of the circle.
Nature Geometry
Scope Fractions or decimals are accepted values. No negative
values for the radius should be accepted.
Input The values of pi and radius.
Output The area of the circle.
Process
40
09/10/2022
Problem Analysis
Problem 2
Statement of the Problem Write a program that will compute the area of a circle.
Definitive Statement of the Give the computer the values of pi and radius. It should
Problem be able to square the radius then multiply by pi to get
the area of the circle.
Algorithm Design
• Algorithm is a set of rules for solving a problem in a finite number of steps.
41
09/10/2022
Algorithm Design
Definition
• It is a technique that emphasizes the breaking of a program or algorithm into logical
sections, or modules following a universal programming standard. (breaking of
programs into smaller modules)
42
09/10/2022
43
09/10/2022
• Let your program or algorithm make a decision. Choose one from two sets of
instructions depending on the condition. IF (condition) THEN (Process 1) ELSE
(Process 2).
44
09/10/2022
45
09/10/2022
3.3.1 Flowchart
Definition
3.3.2 Flowchart
Flowcharting Symbols
46
09/10/2022
3.3.3 Flowchart
Examples of Flowcharts
3.3.3 Flowchart
Examples of Flowcharts
47
09/10/2022
3.3.3 Flowchart
Examples of Flowcharts
3.4.1-2 Pseudocode
48
09/10/2022
3.4.3 Pseudocode
Pseudocode Example
Problem 1
Statement of the Problem Write a program to determine the sum of two numbers.
Pseudocode BEGIN
INPUT the first number
INPUT the second number
Add the two numbers
OUTPUT the sum
END
CHAPTER
1
CC 102 Fundamentals of Programming
OVERVIEW OF
COMPUTER
AND PROGRAMMING
Part 4: Coding and Debugging
49
09/10/2022
CHAPTER
1 Topic Outline
• Introduction
CC 102 Fundamentals of Programming
OVERVIEW OF • Coding
• Debugging
COMPUTER
AND PROGRAMMING
Part 4: Coding and Debugging
4.1.1 Introduction
• Once you have designed the algorithm and verified its correctness, the next step is to
convert it into an equivalent programming code. You then use a text editor to
enter the programming code or the program into a computer.
• Next, you must make sure that the program follows the language’s syntax. To
verify the correctness of the syntax, you run the code through a compiler.
• If the compiler generates error messages, you must identify the errors in the
code, remove them, and then run the code through the compiler again. When
all the syntax errors are removed, the compiler generates the equivalent machine
code, the linker links the machine code with the system’s resources, and the loader
places the program into main memory so that it can be executed.
50
09/10/2022
4.2.1 Coding
Problem 1
Statement of the Write a program to determine the sum of two numbers.
Problem
4.2.1 Debugging
Definition
51
09/10/2022
4.2.1 Debugging
Kinds of Errors
Syntax Error
Run-Time Error
Linker Error
Logical Error
Semantic Error
52