Introduction To Programming: C Language

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 18

Introduction to Programming

C Language
• PROGRAMMING is the art and science of
creating programs. A program is a list of
organized instructions that the computer must
follow in order to process data into
information.
• Programming also called software
engineering, is a multi step process for
creating a program.
• Programming is also called a method of
solving a problem.
• Programming uses algorithms – an algorithms
being a set of ordered steps for solving a
problem, and which is essentially synonymous
with logic. Analytical and critical thinking is
needed in the formulation of solutions to a
problem.
Program Development Process
Problem Analysis

Program Design

Program Coding

Program Testing and


Debugging

Program Documentation
and Maintenance
Steps in Program Development
• First Step: Problem Analysis
Problem Analysis is defined by the American
National Standards Institute (ANSI) as the
“methodical investigation of a problem and the
separation of the problems into smaller related
units for further detailed study.”
Problem Analysis requires performing the
following steps:

1. Define the problem and the user.


2. Determine the desired outputs
3. Determine the desired inputs
4. Determine the desired processing
5. Double-check the feasibility of implementing
the program
6. Document the analysis
• Second Step: Program Design
The program design process describes the
algorithm for the solution of the problem.
Algorithms specify what actions and
operations a program will take. A programmer
has several program design tools to choose
from – flowcharts, decision tables, or pseudo
codes – in formulating the algorithm.
• Program Design requires performing the following
steps:
1. Determine the program logic using a top-down
approach and modularization.
2. Design details using a pseudo code and/or
flowcharts.
Pseudo Code: (pseudo means fake) is an algorithm
written in a normal human-language statements to
describe the logic and processing flow.
Flowcharts: is a visual outline of an algorithm in which
the steps and process to be followed are represented
by symbols.
• Two kinds of flowcharts:
System Flowchart is a diagrammatic
representation of the broad flow of work,
documents and operations. It shows what job
to be done.
Program Flowchart is a diagrammatic
representation of a solution to a given problem
for which the program is written. It shows how
the job to be done. Thus, program flowchart
outlines the details of the sequence of
operations to be executed.
3. Do a structure walkthrough
There is an established part of the design phase
called structured walkthrough. It is a method
of examining computer system, including its
design and implementation, in a systematic
way.
• Sample Problem: Determine the total score of
a students in 3 quizzes.
• Solution:
Input: Q#1, Q#2, Q#3, 3 no. of
quizzes.
Processing: Total_Score = Q#1+Q#2+Q#3
Output: Total_Score
• Specific Problem: Determine the total score of
Marie in 3 quizzes. Given data are 8, 10, and
9.
• Solution:
Input: Q1=8, Q2=10, Q3=9, n = 3
Processing: Total = Q1+Q2+Q3
Total = 8 + 10 + 9
Output: Total = 27
Step 1: Problem Analysis
• Define the problem: Determine the total score
of a students in 3 quizzes.
• Determine the desired output: Total Score
(Note: No output format, such as printing the total at a particular location, was
required)

• Determine the desired inputs: Q1=8, Q2=10,


Q3=9 (or scores in 3 quizzes, Q1, Q2, Q3,
where given data are 8, 10 and 9 respectively)
• Determine the desired processing:
Total = Q1 + Q2 + Q3
• Double check the feasibility of implementing the
program:
Yes, the program can be implemented. The input
can be obtained. The formulas, the software or
program needed and the other processing requirements
are available.
• Document the Analysis:
The program is used to determine the total score of
a student in three quizzes.
The data represents the scores of a student. The
total score is a set of values determined by adding all
the values, that is, the formula to be used is TOTAL =
Q1 + Q2 + Q3
The variable documentation is as follows:
TOTAL = total score
Q1 = score on the first quiz
Q2 = score on the second quiz
Q3 = score on the third quiz
Step 2: Program Design
• Determine the program logic using the top –
down approach modularization.
TOTAL
Problem

Read Calculate Generate


Input Total Output

Read Generate
Student’s Record Printout
• Design Details using pseudo code and/or
flowchart.
The algorithm: 1. Get the student’s score in 3 quizzes
2. Calculate the total score
3. Display the Score

The pseudo code: Read Q1, Q2, Q3


Calculate : TOTAL = Q1 + Q2 + Q3
Write TOTAL
Program Start
Flowchart
Total=0, Q1=0,
Q2=0, Q3=0

Input Q1, Q2, Q3

Total = Q1 + Q2 + Q3

Display
Total

End

You might also like