Cos Merged
Cos Merged
Computer Programming I
Module 1:Introduction to Computer
Programming
Introduction
Computers are used for various tasks in various settings,
such as school, work, and home. Creating applications to
run these tasks
How do we make these applications to handle these tasks?
We program these apps to perform diverse functions
through software created by programmers and developers.
A programmer, or software developer, is a person with the
training and skills necessary to design, create, and test
computer programs.
Computer programming is an important and versatile
career employed across many industries and fields.
In this course we will be learning how this application are
Computer Programming
A program is a set of instructions that tells the computer what to do.
Computer programming (often shortened or coding), is the process of;
writing, testing, debugging/troubleshooting and maintaining instructions
(source code) for solving a problem with the computer.
A source code is written in an acceptable computer programming
language. (C++, Java, Python etc.)
The purpose of programming is to create a program that exhibits a
certain described behaviour (customization).
The process of writing source code requires expertise in many
different subjects, including knowledge of the application domain.
What is Programming
Programming is the craft of transforming requirements
into something that a computer can execute.
It is also the process of creating a set of instructions
(called a program) that tells a computer how to perform a
task. It involves:
Writing precise, step-by-step commands
Using specific programming languages that the computer can
understand
Converting human thoughts and solutions into machine-executable
format (Coding)
Why Programming Matters
An essential skill for problem-solving
programming is a fundamental tool for problem-solving, as
it allows for;
The development of analytical and logical thinking,
The automation of tasks,
The modelling and simulation of scenarios,
The manipulation and analysis of data,
The rapid prototyping of solutions,
These capabilities make programming an essential skill
for effective problem-solving in a wide range of
domains.
Key Ways Programming Contributes To
Problem-Solving
Algorithmic Thinking: Programming requires the ability to break
down complex problems into a series of logical steps or
algorithms. This helps develop analytical and problem-solving
skills
Automation: Programming allows for the automation of
repetitive or tedious tasks, freeing up time and resources to
focus on more complex problem-solving.
Planning my resumption
Using the Problem-Solving Process, to help solve this
problem of a student preparing for school resumption
after a break.
Example: Planning for school resumption
Problem Identification
Understanding what needs to be solved: The student needs to
get ready for school.
Identifying inputs and required outputs: The student needs school
supplies (notebooks, pens, textbooks), a schedule for classes, and
potentially new clothes.
Determining constraints and requirements: There’s a limited budget
for new supplies, and the student needs to be ready by a specific
date.
Problem Analysis
Breaking down complex problems into smaller parts:
Create a list of required supplies, review the school schedule, and
plan clothing needs.
Identifying patterns and relationships: Analyze which subjects require
specific textbooks and what items are left over from the previous
term.
Determining necessary resources: Check what supplies can be reused
and what needs to be bought.
Planning for school resumption
Solution Design
Creating algorithms: Outline the steps to follow:
List all subjects for the new term.
Research the needs for each subject (books, materials).
Create a shopping list for supplies and clothes.
Set aside time for back-to-school shopping.
Planning data structures: Use a checklist or a digital app to
track what items are needed and which ones have already been
purchased.
Implementation
Writing the actual code: In this context, it means putting the
plan into action—shopping for supplies, organizing the
backpack, and laying out clothes for the first day.
Testing and debugging: After shopping, check to ensure all
items on the list have been bought; if something is missing,
adjust plans to acquire it.
Optimizing performance: If the budget is tight, prioritize
essential items first and consider second-hand options for items
that are still in good condition.
COS 201
Computer Programming I
Algorithm
Algorithms
The steps to the solutions are broken into a series of logical steps in
English-like form
There can’t be a solution if there is no recognized problem and once a
problem exists, one must take certain steps in order to get a desired
solution.
The methods that can be used include;
English-like form (Pseudo code)
Flowchart
Decision table
Pseudo Code
Address Envelop
Place in
Envelop
Have
stamp
Place in Envelop
Place in
Envelop
Stop
Example 1
Write an algorithm and draw a flowchart to convert the length in feet to
centimeter.
Start
(Pseudocode)
Input the length in feet (Lft) Input Lft
Print LCM
Step 1: Input Lft
Step 2: Lcm ← Lft * 30
Stop
Step 3: Print Lcm Step 4: Stop
Uses of Flow chart
Easy to understand
Conditions: These are the inputs that trigger different actions. Each
condition can have two or more possible states (e.g., true/false,
high/low).