Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
4 views

Algorithm

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Algorithm

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

COMP101

WHAT IS COMPUTER PROGRAM?


• A program is a set of instructions that is
written in the language of the computer.
• A program is used to make a computer
perform a specific task.
• It receives data, carry out the instructions,
and produce useful results.
WHAT IS PROGRAMMING?
• Also called Programming or Coding.
• This refers to the process of writing
computer programs using a programming
language.
• The process of writing, testing,
debugging/troubleshooting, and maintaining
the source code of computer programs.
WHAT IS PROGRAMMING LANGUAGE?
• An artificial language that can be used to write programs
which control the behavior of a machine, particularly a
computer.
• Programming languages used to create computer programs.
• Defined by syntactic/syntax and semantic rules which
describe their structure and meaning respectively.
⚬ Syntax: Punctuation such as parentheses, braces, brackets, semi-
colons, etc.
⚬ ·Semantics: The meaning of different symbols, e.g. =, +, and other key
words
WHAT IS PROGRAMMER?
• Is a person who prepares instructions for
computers.
• Receives directions from a systems analyst
• Also known as software developer.
• Write, test and maintain the detailed
instructions (computer programs), that
computers must follow to perform their
functions.
• ADA LOVELACE born as Augusta Ada Byron, was an English
writer chiefly known for her work on Charles Babbage's early
mechanical general-purpose computer, the analytical engine.
• Countess of Lovelace (born 10 December 1815 – 27 November
1852)
• She was the first to recognise that the machine had
applications beyond pure calculation, and to have published
the first algorithm intended to be carried out by such a
machine.
• She is portrayed in popular culture as the "World's First
Computer Programmer".
ADA LOVELACE
• Low-level language
• High-level language
LOW LEVEL LANGUAGE
• The low-level language is a programming language that
provides no abstraction from the hardware, and it is
represented in 0 or 1 forms, which are the machine
instructions.
Classified into two generations:
• First Generation - Machine languages
• Second Generation -Assembly languages
HIGH - LEVEL LANGUAGE
• The high-level language is a programming language that
allows a programmer to write the programs which are
independent of a particular type of computer. The high-
level languages are considered as high-level because they
are closer to human languages than machine-level
languages.
• High level languages are problem-orientated whereas low
level languages are machine-orientated.
• Examples include: C++, Java, Pascal, Python, Visual Basic.
1. Define the Problem
2. Design a Test Plan
3. Design a Solution
✓ Must understand exactly what the problem is, before we
can begin to solve it.
✓ Must answer such questions as “Which?”, “How?” and
“What?”.

•Define the Scope and Generality of the Solution Needed


•Define the Input and Output
•Define Constants and Formulas
•Define Basic Computational Needs
✓ Verification is an essential step in program
development.

✓ a Test Plan consists of a list of input data sets


and the correct program result for each, which
often must be computed by hand.
• Select and Create an Algorithm
• Design the Driver
➢ a part of the program that forms the interface between
the user and the computation.
• Design Debugging Printouts
➢ frequent output statements
➢ scattered throughout your code, let you know what is
happening.
➢ used to display the input values before computation
starts and the results after each important computation.
• a list of instructions for carrying out some process
step by step.
• a method for solving a well-structured problem.
• the method must be completely defined,
unambiguous and effective.
• must terminate; it cannot go on forever.
Steps in cooking pinakbet:

• Sauté pork until light brown.


• Add bagoong, onions and ginger.
• Bring to boil.
• Simmer a few minutes.
• Add the rest of the ingredients.
• Cover and simmer for 15 minutes.
Problem: Write an algorithm to read an
integer A then display the value of the
integer.

Algorithm:
• Read an integer A.
• Display the value of integer A.
Problem: Construct an algorithm to read the three
integers X, Y, Z. Compute the sum of the three integers
then store to variable SUM. Display the result.

Algorithm:
• Read the value of the three integers X, Y, Z.
• Compute the sum using the formula SUM = X+Y+Z.
• Print SUM.
Problem: Create an algorithm that will input values for
A and B. Compare two values inputted and print which
of the values is higher including the remark “Higher”

Algorithm:
• Read A & B
• if A is greater than B then
• Print "A is Higher"
• else Print "B is Higher"
1.Write an algorithm to compute the average of three
input quizzes. Then display the result.

2.Create an algorithm to convert the input dollar(s) into


its equivalent peso. One dollar is approximately equal to
50.60 pesos. Then display the result.

3.Write a program the converts the input Celsius degree


into its equivalent Fahrenheit degree. Use the formula: F
= (9/5) *C+32.
4. Given three numbers A, B, and C. Construct the
algorithm to compute and print out the sum, the average,
and the product of these values.
1.ALGORITHM:
• INPUT > Enter the three quizzes (q1,q2,q3)
• PROCESS > Compute the average [ave = (q1 + q2 + q3) / 3]
• OUTPUT > Display the average (ave)

2.ALGORITHM:
• Enter the amount of dollar
• Compute Peso = dollar * 50.60
• Display the equivalent peso
3.ALGORITHM:
• Read Temperature in Celsius
• Compute the F by using the formula f = C 5/9*(F32)
• Print Temperature in F

4.ALGORITHM:
• Read the three number supposed "a","b","c"
• Compute the sum=a+b+c; ave = a+b+c/3; product = a*b*c
• Display “sum “ ,"ave“, and “product”
1.Write an algorithm to compute the average of three
input quizzes. Then display the result.

2.Create an algorithm to convert the input dollar(s) into


its equivalent peso. One dollar is approximately equal to
50.60 pesos. Then display the result.

3.Write a program the converts the input Celsius degree


into its equivalent Fahrenheit degree. Use the formula: F
= (9/5) *C+32.

You might also like