Introduction to Computer
Programming
CS 111 -Computer Programming
What is Computer Programming?
Computer Programming Programmers Programming Language
It means giving Programmers are the Programmers use a
instruction or directions people who write special language called,
to accomplish specific computer programs. programming languages
task. to communicate with the
computer.
There are approximately 9000+ programming languages used by software and
web developers and other professionals.
Programming Language Categories
1. Machine Language - low level languages and can directly understand by
computer but difficult to ready by humans.
2. Assembly Language - a representation of machine language. These are
instructions translates to machine language instruction called assembler.
3. High Level Language - these are mostly used by programmers today. These
are easy to read and portable. High level languages can be classified into
functional, procedure oriented , object-oriented programming (OOP) and
Logic programming languages.
Challenge 1: Fill in the blanks (not graded)
1. __________________ language is written in 0s and 1s and can be directly
understood by the computer.
2. __________________ language is the easiest to understand, uses words
similar to human language, and is widely used by programmers today.
3. __________________ language uses simple words or mnemonics like "ADD" or
"SUB" to make it easier for humans to write instructions.
Challenge 1: Fill in the blanks (not graded)
4. __________________ refers to giving instructions to a computer to accomplish
a specific task.
5. A __________________ is the person who writes the instructions or code for a
computer to follow.
6. A __________________ is a special language that programmers use to
communicate with the computer.
Getting Started: C++ Programming
You can download and install
any C++ Integrated
development Environment
(IDE) in google play store or
app store compatible to your
smartphones, tablet or laptop.
How it Works: Code Translator from source code to
executable output.
The compiler converts programming language program to machine language while interpreter converts
programming languages to machine language line by line and interpreter use assembly language to convert
programs to machine code.
Challenge 2: Fill in the blanks (not graded)
1. The __________________ is where the programmer writes the code in a high-level
programming language like C++.
2. The __________________ translates the source code into an intermediate object
code, which is closer to machine code but still not executable.
3. After the compiler, the __________________ converts the object code into machine
code, which is a series of 0s and 1s the computer can directly understand.
4. Once the code is in __________________, the computer can execute it and perform
the task the programmer intended.
Problem Solving Process:
Programming is the process of solving problem using algorithms and that requires computer solution.
You will learn how to create a computer solution to a specific problem by applying pseudo-code,
input-process-output (IPO), flowcharts and algorithms.
Steps in problem solving process:
STEP 1: Analyze the problem - Problem outline and list of requirements.
STEP 2: Plan the algorithm - Design algorithm using pseudo-code, IPO and flowcharts.
STEP 3: Check the algorithm - Trace algorithm.
STEP 4: Code the algorithm into a program - Implement algorithms into code.
STEP 5: Maintenance - Evaluate and modify the program if necessary. IPO chart is also applicable.
Definition of Terms
Algorithm - step by step solution to solve a problem or to accomplish specific task.
Flowchart - graphical representation of algorithm. There are symbols and illustration to
use.
Pseudo code - tool to plan the algorithm and use short English statements.
Programs - instruction given to a computer.
IPO Chart -use to organized the result of program analysis.
Example: Calculate the sum of two numbers
INPUT-PROCESS-OUTPUT
Input: num1, num2
Process: sum = num1 + num2
Output: sum
Example: Calculate the sum of two numbers
ALGORITHM
1. Start
2. Input two numbers
3. Add the numbers
4. Display the sum
5. End
Example: Calculate the sum of two numbers
FLOWCHART
START
num1 = 5,
num2 = 3,
sum
sum = num1 + num2
Print sum
END
Example: Calculate the area of a rectangle
INPUT-PROCESS-OUTPUT
Input: Length of the rectangle, width of the rectangle
Process: Multiply the length by the width
Output: The area of the rectangle
Example: Calculate the area of a rectangle
ALGORITHM
1. Start
2. Input the length of the rectangle
3. Input the width of the rectangle
4. Compute the area using the formula: Area = Length x Width
5. Display the Area
6. End
Example: Calculate the area of a rectangle
FLOWCHART
START
Length = 10
Width = 10
Area = 10 x 10
Print Area
END
Data Types, Variables and
Operators
Data Types
Data Types
Syntax: dataType varaibleName = value;
Example below:
Data Types
Syntax: const dataType varaibleName = value;
Example below:
Operators in C++
Practice Exercise 1: (not graded)
Use algorithm, pseudo code and flowchart to
find the area of a circle.
.