SlideShare una empresa de Scribd logo
1 de 6
Descargar para leer sin conexión
Introduction to Computer Programming
3
1.1 The Making of an Art
The impact of the digital computer in the twentieth century is so great that the
computer has become a vital component in our society. "It has practically touched
every aspect of our lives."[LEES90] It helps us in our business transactions, keeps
track of products' inventories, diagnoses heart conditions, recognizes speech patterns,
and provides entertainment through games, among a hundred other applications. Its
impact is so great that "it has revolutionized our society and made us re-examine
certain basic assumptions about our own role in the universe."[HORO86] "Computers
have evolved from a scientific curiosity to an indispensable tool in virtually all areas
of our lives."[SAVI89]
However true it is that computers can solve problems efficiently and
accurately and how sophisticated it can be, it still cannot think for itself - it cannot
solve problems on its own. It's the human being who understands, thinks, and solves
problems on its own and who gives correct instruction that directs the computer to
solve problems. The set or list of instructions that directs the computer on its
operations is called a computer program. The person who develops a program is
called a programmer. The act of developing a program is called programming.
Computer programming is not just plainly
listing down lengthy steps to be communicated to
the computer. It is not a matter of "just write
anything and make it run". The programmer must
learn to put his logic and his creativity to
make his work a masterpiece. Computer
programming needs to be an art!
1.2 Steps in Program Planning and Development
Programming is a problem-solving activity. A person with good problem solving
skills will tend to be good programmers. To develop this skill, programmers practice
the following steps:
1. problem analysis
2. setting up an algorithm
3. coding
4. encoding
5. running, testing, and debugging
6. documentation
Chapter 1
4
1.2.1 Problem Analysis
If we are to use the computer as a problem-solving tool then we must have a good
analysis of the problem given. Here are some suggested steps on how to go about
analyzing a certain problem for computer application:
1. Review the problem carefully and understand what you are asked to do.
2. Determine what information is given (input) and what result must be produced
(output).
3. Assign names to each input and output item.
4. Determine the manner of processing that must be done on the input data to
come up with the desired output (i.e., determine what formulas are needed to
manipulate the given data).
Example.
Given the scores for the two departmental quizzes, two machine projects, final
exam, and teacher's evaluation, write a program that will compute for the final
grade based on the following computation:
50% Average of 2 departmental quizzes
+ 15% Average of 2 machine projects
+ 30% Final exam
+ 5% Teacher's evaluation
--------------------------------------------------------
Quiz No. 1 - Qz1 Final Grade - FG
Quiz No. 2 - Qz2
Mach. Proj. 1 - Mp1
Mach. Proj. 2 - Mp1
Final Exam - FE
Teacher's Eval. - TE
Qz1+Qz2 Mp1+Mp2
FG = 50% x ------------ + 15% x ----------- + 30% x FE + 5% x TE
2 2
1.2.2 Setting Up an Algorithm
After the problem has been clearly defined, a list or sequence of steps that will solve
the given problem must be formulated. This sequence of steps is called an algorithm.
An algorithm can be described in many ways. A natural language such as
Filipino, English, or Chinese can be used but we must be very careful that the
Introduction to Computer Programming
5
algorithm be organized in a logical and clear manner. Graphical forms or notations
such as flowcharts can be used, an improvement of the former, but is more
sophisticated. It is important to note that in whatsoever manner an algorithm is
written, it remains to be NOT executable simply because it cannot be entirely
understood by the computer.
To cite an example, let us use the final grade problem. A possible algorithm
written in English that will solve the problem would be:
1. Get Qz1 and Qz2 scores.
2. Get Mp1 and Mp2 scores.
3. Get FE score.
4. Get TE score.
5. Calculate
Qz1+Qz2 Mp1+Mp2
FG = 50% x ------------ + 15% x ----------- + 30% x FE + 5% x TE
2 2
6. Display the final grade FG.
An algorithm may also be viewed as a recipe. The manner in which the series
of steps in a recipe is written is similar to creating an algorithm. But, it should be
noted that an algorithm is more than a recipe. An algorithm has to be exact. An
example statement in a recipe would be “add salt to taste”. In an algorithm, this is not
acceptable because the statement is subjective and not quantifiable. Everything
should be definite.
1.2.3 Coding
After having set up the algorithm, the next step is to convert this into a list of
instructions in a code or language that the computer can understand and execute. This
process is called coding.
Chapter 1
6
Example.
Algorithm Program
The list of instructions that will implement the algorithm can be understood
by the computer simply because "it is written in the vocabulary of the programming
language and conforms to the grammatical rules of the language."[LEES90] This list
of instructions understood by the computer is now called a program.
In the example above, we converted our algorithm for computing the final
grade to a C program. The scanf statements ask for input from the user while the
printf statement displays the output.
1.2.4 Encoding
The process of entering the program through a computer terminal directly into
computer memory is called encoding.
1.2.5 Running, Testing, and Debugging
The fifth step in program development would be to execute or run the program. The
program is executed or run on different input data. Testing is the art of creating
Get Qz1 and Qz2 scores.
Get Mp1 and Mp2 scores.
Get FE score.
Get TE score.
Calculate FG.
Display the final grade
FG.
main()
{ float fQ1, fQ2;
float fMP1, fMP2;
float fFE, fTE, fFG;
scanf("%f", &fQ1);
scanf("%f", &fQ2);
scanf("%f", &fMP1);
scanf("%f", &fMP2);
scanf("%f", &fFE);
scanf("%f", &fTE);
fFG = 0.50 * ((fQ1 +
fQ2)/2) + 0.15 *
((fMP1 + fMP2)/2) +
0.3 * fFE + 0.05 *
fTE;
printf("FG = %.2fn",
fFG);
}
Introduction to Computer Programming
7
Did you know that...
The term bug dates back
to an old story about a group of
programmers who couldn't
figure out what was wrong with
their programs, until they
opened up the computer and
found a moth trapped inside
[REGE87]
different sets of sample data upon which the program will be run. The programmer
must submit the program to as many combinations of test data as possible to
anticipate and correct any error that might come out before releasing the program to
users. The process of executing a program with test input data and checking the
output results against the requirements is referred to as desk checking [PRAT96].
Errors that come out during program execution are termed as bugs. Computer
programmers use terms as bug-ridden and buggy to describe a program which is
poorly written thus containing a lot of errors. The art of correcting these errors is
called debugging.
These bugs or errors can be classified
into two groups: 1. syntactical or logical errors;
and 2. compile or run-time errors.
Syntactical errors result from failure to
follow the syntax of the language. Syntax refers
to the grammatical rules of the language
defining its legal constructs. Examples of which
are unrecognized instructions, missing
punctuation marks and misspelled names.
Logical errors are hard to identify.
What is erroneous here are the outputs seen
onscreen which did not conform to or match the
expected results. Such errors arise during the
formulation of algorithm or in the coding of the program that implements the
algorithm due to the wrong analysis or perhaps wrong approach of the programmer as
he tackles the problem given.
Compile-time errors halt the compilation of the program. Compilation means
translating the program codes into a form that the physical computing machine can
understand. Program codes are translated completely so long as their syntax is correct.
Once a syntax error is encountered during compilation, this is considered to be a
compile-time error.
Errors that appear during program execution are called run-time errors. Once
a program starts running, it means that the program is already free of syntax errors
and compilation has successfully finished. However, it may still have logical errors
that may cause the abnormal termination of the program. An example would be
dividing a certain number by zero. Another would be the program executing in an
endless loop wherein the only way to stop it is to manually stop the execution of the
program.
Chapter 1
8
1.2.6 Documentation
There are three basic types of documentation. The most common type of
documentation is the user’s manual. Software usually comes with a user’s manual
and it contains information on the software and hardware requirements, installation
procedures, and step-by-step instructions on how to use the system. This type of
documentation is used by the user of the program.
In the process of making sure that the program is error-free, running correctly
and efficiently, documentation of the program must be done. The purpose of which is
to maintain the relevance and validity of the program. For the next two types of
documentation, the process must be continuous. Programs in real-world applications
will likely be used for a number of years and will probably require some modification
as time passes. Especially in large programs developed for complex projects, there
will usually be obscure bugs that do not become apparent until after the program has
been placed in use.[LEES90] Such modifications made due to further discovering
errors while the program is in use must be documented well. Ten years after the
program has been written, someone may want to update it and the first thing he'll do
is to look at the documentation of the program to become aware of the details of the
program. Good documentation reduces program maintenance efforts and major
problem reconstruction. These are the objectives of creating the technical manual and
internal documentation.
The technical manual is a printed copy of the information regarding how the
program was designed and how it was created. Issues involved in choosing the data
type or data structure, as well as the algorithm for the solution, are also included. On
the other hand, the internal documentation has the same information but these are
stored within the program themselves, through the use of comments.

Más contenido relacionado

La actualidad más candente

High level and Low level Language
High level and Low level Language High level and Low level Language
High level and Low level Language adnan usmani
 
Programming languages
Programming languagesProgramming languages
Programming languagesSimon Mui
 
Lesson 1 - Introduction to Computer Programming.pptx
Lesson 1 - Introduction to Computer Programming.pptxLesson 1 - Introduction to Computer Programming.pptx
Lesson 1 - Introduction to Computer Programming.pptxNeil Mutia
 
Basic Computer Programming
Basic Computer ProgrammingBasic Computer Programming
Basic Computer ProgrammingAllen de Castro
 
Introduction to computer programming
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programmingNSU-Biliran Campus
 
Introduction to Programming Languages
Introduction to Programming LanguagesIntroduction to Programming Languages
Introduction to Programming Languageseducationfront
 
Programming language
Programming languageProgramming language
Programming languageShuja Qais
 
Introduction of c programming
Introduction of c programmingIntroduction of c programming
Introduction of c programmingTarun Sharma
 
Lect 1. introduction to programming languages
Lect 1. introduction to programming languagesLect 1. introduction to programming languages
Lect 1. introduction to programming languagesVarun Garg
 
Programming languages
Programming languagesProgramming languages
Programming languagesAsmasum
 
Programming Fundamental Slide No.1
Programming Fundamental Slide No.1Programming Fundamental Slide No.1
Programming Fundamental Slide No.1Arslan Hussain
 
Programming Fundamentals lecture 1
Programming Fundamentals lecture 1Programming Fundamentals lecture 1
Programming Fundamentals lecture 1REHAN IJAZ
 
Intro To Programming Concepts
Intro To Programming ConceptsIntro To Programming Concepts
Intro To Programming ConceptsJussi Pohjolainen
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programmingManoj Tyagi
 

La actualidad más candente (20)

High level and Low level Language
High level and Low level Language High level and Low level Language
High level and Low level Language
 
Programming languages
Programming languagesProgramming languages
Programming languages
 
Lesson 1 - Introduction to Computer Programming.pptx
Lesson 1 - Introduction to Computer Programming.pptxLesson 1 - Introduction to Computer Programming.pptx
Lesson 1 - Introduction to Computer Programming.pptx
 
Computer Programming
Computer ProgrammingComputer Programming
Computer Programming
 
Computer Programming
Computer Programming Computer Programming
Computer Programming
 
Basic Computer Programming
Basic Computer ProgrammingBasic Computer Programming
Basic Computer Programming
 
Introduction to computer programming
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programming
 
Introduction to Programming Languages
Introduction to Programming LanguagesIntroduction to Programming Languages
Introduction to Programming Languages
 
Programming language
Programming languageProgramming language
Programming language
 
Introduction of c programming
Introduction of c programmingIntroduction of c programming
Introduction of c programming
 
Lect 1. introduction to programming languages
Lect 1. introduction to programming languagesLect 1. introduction to programming languages
Lect 1. introduction to programming languages
 
Programming languages
Programming languagesProgramming languages
Programming languages
 
Programming Fundamental Slide No.1
Programming Fundamental Slide No.1Programming Fundamental Slide No.1
Programming Fundamental Slide No.1
 
Programming Fundamentals lecture 1
Programming Fundamentals lecture 1Programming Fundamentals lecture 1
Programming Fundamentals lecture 1
 
Intro To Programming Concepts
Intro To Programming ConceptsIntro To Programming Concepts
Intro To Programming Concepts
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
Introduction to programming languages
Introduction to programming languagesIntroduction to programming languages
Introduction to programming languages
 
Programming Language
Programming LanguageProgramming Language
Programming Language
 
Translators(Compiler, Assembler) and interpreter
Translators(Compiler, Assembler) and interpreterTranslators(Compiler, Assembler) and interpreter
Translators(Compiler, Assembler) and interpreter
 
Computer programming concepts
Computer programming conceptsComputer programming concepts
Computer programming concepts
 

Destacado

Introduction to basic programming
Introduction to basic programmingIntroduction to basic programming
Introduction to basic programmingJordan Delacruz
 
Introduction to HTML
Introduction to HTMLIntroduction to HTML
Introduction to HTMLAmit Tyagi
 
Introduction to computer programming
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programmingNoel Malle
 
Webinar - Introduction to Programme Management, 23 February 2017, Alan Macklin
Webinar - Introduction to Programme Management, 23 February 2017, Alan MacklinWebinar - Introduction to Programme Management, 23 February 2017, Alan Macklin
Webinar - Introduction to Programme Management, 23 February 2017, Alan MacklinAssociation for Project Management
 
Search engines powerpoint
Search engines powerpointSearch engines powerpoint
Search engines powerpointvbaker2210
 
Introduction to Search Engines
Introduction to Search EnginesIntroduction to Search Engines
Introduction to Search EnginesNitin Pande
 
Writing effective emails
Writing effective emailsWriting effective emails
Writing effective emailsDixita S
 
Introduction to HTML
Introduction to HTMLIntroduction to HTML
Introduction to HTMLMayaLisa
 
Search engines and its types
Search engines and its typesSearch engines and its types
Search engines and its typesNagarjuna Kalluru
 

Destacado (19)

Computer Programming- Lecture 11
Computer Programming- Lecture 11Computer Programming- Lecture 11
Computer Programming- Lecture 11
 
About search engines
About search enginesAbout search engines
About search engines
 
Introduction to basic programming
Introduction to basic programmingIntroduction to basic programming
Introduction to basic programming
 
Introduction to HTML
Introduction to HTMLIntroduction to HTML
Introduction to HTML
 
Lecture 12: Classes and Files
Lecture 12: Classes and FilesLecture 12: Classes and Files
Lecture 12: Classes and Files
 
Introduction to computer programming
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programming
 
Webinar - Introduction to Programme Management, 23 February 2017, Alan Macklin
Webinar - Introduction to Programme Management, 23 February 2017, Alan MacklinWebinar - Introduction to Programme Management, 23 February 2017, Alan Macklin
Webinar - Introduction to Programme Management, 23 February 2017, Alan Macklin
 
Computer Programming - Lecture 1
Computer Programming - Lecture 1Computer Programming - Lecture 1
Computer Programming - Lecture 1
 
Search engines powerpoint
Search engines powerpointSearch engines powerpoint
Search engines powerpoint
 
Computer Programming- Lecture 4
Computer Programming- Lecture 4Computer Programming- Lecture 4
Computer Programming- Lecture 4
 
Computer Programming- Lecture 3
Computer Programming- Lecture 3Computer Programming- Lecture 3
Computer Programming- Lecture 3
 
Introduction to Search Engines
Introduction to Search EnginesIntroduction to Search Engines
Introduction to Search Engines
 
Writing effective emails
Writing effective emailsWriting effective emails
Writing effective emails
 
Search engines
Search enginesSearch engines
Search engines
 
Search Engine
Search EngineSearch Engine
Search Engine
 
Introduction to HTML
Introduction to HTMLIntroduction to HTML
Introduction to HTML
 
Email Writing Skills
Email Writing SkillsEmail Writing Skills
Email Writing Skills
 
Search engines and its types
Search engines and its typesSearch engines and its types
Search engines and its types
 
Search Engines
Search EnginesSearch Engines
Search Engines
 

Similar a Introduction to Computer Programming

Chapter 2(1)
Chapter 2(1)Chapter 2(1)
Chapter 2(1)TejaswiB4
 
Program concep sequential statements
Program concep sequential statementsProgram concep sequential statements
Program concep sequential statementsankurkhanna
 
Stnotes doc 5
Stnotes doc 5Stnotes doc 5
Stnotes doc 5Alok Jain
 
Unit 1 python (2021 r)
Unit 1 python (2021 r)Unit 1 python (2021 r)
Unit 1 python (2021 r)praveena p
 
What is algorithm
What is algorithmWhat is algorithm
What is algorithmmshoaib15
 
Programming_Lecture_1.pptx
Programming_Lecture_1.pptxProgramming_Lecture_1.pptx
Programming_Lecture_1.pptxshoaibkhan716300
 
PCCF UNIT 1.pptx
PCCF UNIT 1.pptxPCCF UNIT 1.pptx
PCCF UNIT 1.pptxDivyaKS12
 
L1. Basic Programming Concepts.pdf
L1. Basic Programming Concepts.pdfL1. Basic Programming Concepts.pdf
L1. Basic Programming Concepts.pdfMMRF2
 
Computer programing 111 lecture 2
Computer programing 111 lecture 2Computer programing 111 lecture 2
Computer programing 111 lecture 2ITNet
 
Problem Solving Techniques
Problem Solving TechniquesProblem Solving Techniques
Problem Solving TechniquesAshesh R
 
Problem Solving Techniques and Introduction to C
Problem Solving Techniques and Introduction to CProblem Solving Techniques and Introduction to C
Problem Solving Techniques and Introduction to CPrabu U
 

Similar a Introduction to Computer Programming (20)

Chapter 2(1)
Chapter 2(1)Chapter 2(1)
Chapter 2(1)
 
Program concep sequential statements
Program concep sequential statementsProgram concep sequential statements
Program concep sequential statements
 
PROBLEM SOLVING
PROBLEM SOLVINGPROBLEM SOLVING
PROBLEM SOLVING
 
Stnotes doc 5
Stnotes doc 5Stnotes doc 5
Stnotes doc 5
 
Module 1 python.pptx
Module 1 python.pptxModule 1 python.pptx
Module 1 python.pptx
 
grade 10 2023.pptx
grade 10 2023.pptxgrade 10 2023.pptx
grade 10 2023.pptx
 
Unit 1 python (2021 r)
Unit 1 python (2021 r)Unit 1 python (2021 r)
Unit 1 python (2021 r)
 
What is algorithm
What is algorithmWhat is algorithm
What is algorithm
 
Introduction to Programming.docx
Introduction to Programming.docxIntroduction to Programming.docx
Introduction to Programming.docx
 
Programming_Lecture_1.pptx
Programming_Lecture_1.pptxProgramming_Lecture_1.pptx
Programming_Lecture_1.pptx
 
Beekman5 std ppt_13
Beekman5 std ppt_13Beekman5 std ppt_13
Beekman5 std ppt_13
 
PCCF UNIT 1.pptx
PCCF UNIT 1.pptxPCCF UNIT 1.pptx
PCCF UNIT 1.pptx
 
Introduction.pptx
Introduction.pptxIntroduction.pptx
Introduction.pptx
 
L1. Basic Programming Concepts.pdf
L1. Basic Programming Concepts.pdfL1. Basic Programming Concepts.pdf
L1. Basic Programming Concepts.pdf
 
Computer programing 111 lecture 2
Computer programing 111 lecture 2Computer programing 111 lecture 2
Computer programing 111 lecture 2
 
Cp 111 lecture 2
Cp 111 lecture 2Cp 111 lecture 2
Cp 111 lecture 2
 
Problem Solving Techniques
Problem Solving TechniquesProblem Solving Techniques
Problem Solving Techniques
 
Problem Solving Techniques and Introduction to C
Problem Solving Techniques and Introduction to CProblem Solving Techniques and Introduction to C
Problem Solving Techniques and Introduction to C
 
6272 cnote
6272 cnote6272 cnote
6272 cnote
 
C progrmming
C progrmmingC progrmming
C progrmming
 

Más de Prof. Erwin Globio

Cisco Router Basic Configuration
Cisco Router Basic ConfigurationCisco Router Basic Configuration
Cisco Router Basic ConfigurationProf. Erwin Globio
 
Introduction to iOS Apps Development
Introduction to iOS Apps DevelopmentIntroduction to iOS Apps Development
Introduction to iOS Apps DevelopmentProf. Erwin Globio
 
Introduction to Android Development Latest
Introduction to Android Development LatestIntroduction to Android Development Latest
Introduction to Android Development LatestProf. Erwin Globio
 
iOS Apps Development (SQLite Tutorial Part 2)
iOS Apps Development (SQLite Tutorial Part 2)iOS Apps Development (SQLite Tutorial Part 2)
iOS Apps Development (SQLite Tutorial Part 2)Prof. Erwin Globio
 
iOS Apps Development (SQLite Tutorial Part 1)
iOS Apps Development (SQLite Tutorial Part 1)iOS Apps Development (SQLite Tutorial Part 1)
iOS Apps Development (SQLite Tutorial Part 1)Prof. Erwin Globio
 
Solutions to Common Android Problems
Solutions to Common Android ProblemsSolutions to Common Android Problems
Solutions to Common Android ProblemsProf. Erwin Globio
 
Android Development Tools and Installation
Android Development Tools and InstallationAndroid Development Tools and Installation
Android Development Tools and InstallationProf. Erwin Globio
 

Más de Prof. Erwin Globio (20)

Embedded System Presentation
Embedded System PresentationEmbedded System Presentation
Embedded System Presentation
 
BSCS | BSIT Thesis Guidelines
BSCS | BSIT Thesis GuidelinesBSCS | BSIT Thesis Guidelines
BSCS | BSIT Thesis Guidelines
 
Internet of Things
Internet of ThingsInternet of Things
Internet of Things
 
Networking Trends
Networking TrendsNetworking Trends
Networking Trends
 
Sq lite presentation
Sq lite presentationSq lite presentation
Sq lite presentation
 
Ethics for IT Professionals
Ethics for IT ProfessionalsEthics for IT Professionals
Ethics for IT Professionals
 
Cisco Router Basic Configuration
Cisco Router Basic ConfigurationCisco Router Basic Configuration
Cisco Router Basic Configuration
 
Introduction to iOS Apps Development
Introduction to iOS Apps DevelopmentIntroduction to iOS Apps Development
Introduction to iOS Apps Development
 
Cloud Computing Latest
Cloud Computing LatestCloud Computing Latest
Cloud Computing Latest
 
Introduction to Android Development Latest
Introduction to Android Development LatestIntroduction to Android Development Latest
Introduction to Android Development Latest
 
iOS Apps Development (SQLite Tutorial Part 2)
iOS Apps Development (SQLite Tutorial Part 2)iOS Apps Development (SQLite Tutorial Part 2)
iOS Apps Development (SQLite Tutorial Part 2)
 
iOS Apps Development (SQLite Tutorial Part 1)
iOS Apps Development (SQLite Tutorial Part 1)iOS Apps Development (SQLite Tutorial Part 1)
iOS Apps Development (SQLite Tutorial Part 1)
 
A tutorial on C++ Programming
A tutorial on C++ ProgrammingA tutorial on C++ Programming
A tutorial on C++ Programming
 
Overview of C Language
Overview of C LanguageOverview of C Language
Overview of C Language
 
Android Fragments
Android FragmentsAndroid Fragments
Android Fragments
 
Solutions to Common Android Problems
Solutions to Common Android ProblemsSolutions to Common Android Problems
Solutions to Common Android Problems
 
Android Development Tools and Installation
Android Development Tools and InstallationAndroid Development Tools and Installation
Android Development Tools and Installation
 
Java Collections Tutorials
Java Collections TutorialsJava Collections Tutorials
Java Collections Tutorials
 
Action Bar in Android
Action Bar in AndroidAction Bar in Android
Action Bar in Android
 
Resource Speaker
Resource SpeakerResource Speaker
Resource Speaker
 

Último

Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 

Último (20)

Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 

Introduction to Computer Programming

  • 1. Introduction to Computer Programming 3 1.1 The Making of an Art The impact of the digital computer in the twentieth century is so great that the computer has become a vital component in our society. "It has practically touched every aspect of our lives."[LEES90] It helps us in our business transactions, keeps track of products' inventories, diagnoses heart conditions, recognizes speech patterns, and provides entertainment through games, among a hundred other applications. Its impact is so great that "it has revolutionized our society and made us re-examine certain basic assumptions about our own role in the universe."[HORO86] "Computers have evolved from a scientific curiosity to an indispensable tool in virtually all areas of our lives."[SAVI89] However true it is that computers can solve problems efficiently and accurately and how sophisticated it can be, it still cannot think for itself - it cannot solve problems on its own. It's the human being who understands, thinks, and solves problems on its own and who gives correct instruction that directs the computer to solve problems. The set or list of instructions that directs the computer on its operations is called a computer program. The person who develops a program is called a programmer. The act of developing a program is called programming. Computer programming is not just plainly listing down lengthy steps to be communicated to the computer. It is not a matter of "just write anything and make it run". The programmer must learn to put his logic and his creativity to make his work a masterpiece. Computer programming needs to be an art! 1.2 Steps in Program Planning and Development Programming is a problem-solving activity. A person with good problem solving skills will tend to be good programmers. To develop this skill, programmers practice the following steps: 1. problem analysis 2. setting up an algorithm 3. coding 4. encoding 5. running, testing, and debugging 6. documentation
  • 2. Chapter 1 4 1.2.1 Problem Analysis If we are to use the computer as a problem-solving tool then we must have a good analysis of the problem given. Here are some suggested steps on how to go about analyzing a certain problem for computer application: 1. Review the problem carefully and understand what you are asked to do. 2. Determine what information is given (input) and what result must be produced (output). 3. Assign names to each input and output item. 4. Determine the manner of processing that must be done on the input data to come up with the desired output (i.e., determine what formulas are needed to manipulate the given data). Example. Given the scores for the two departmental quizzes, two machine projects, final exam, and teacher's evaluation, write a program that will compute for the final grade based on the following computation: 50% Average of 2 departmental quizzes + 15% Average of 2 machine projects + 30% Final exam + 5% Teacher's evaluation -------------------------------------------------------- Quiz No. 1 - Qz1 Final Grade - FG Quiz No. 2 - Qz2 Mach. Proj. 1 - Mp1 Mach. Proj. 2 - Mp1 Final Exam - FE Teacher's Eval. - TE Qz1+Qz2 Mp1+Mp2 FG = 50% x ------------ + 15% x ----------- + 30% x FE + 5% x TE 2 2 1.2.2 Setting Up an Algorithm After the problem has been clearly defined, a list or sequence of steps that will solve the given problem must be formulated. This sequence of steps is called an algorithm. An algorithm can be described in many ways. A natural language such as Filipino, English, or Chinese can be used but we must be very careful that the
  • 3. Introduction to Computer Programming 5 algorithm be organized in a logical and clear manner. Graphical forms or notations such as flowcharts can be used, an improvement of the former, but is more sophisticated. It is important to note that in whatsoever manner an algorithm is written, it remains to be NOT executable simply because it cannot be entirely understood by the computer. To cite an example, let us use the final grade problem. A possible algorithm written in English that will solve the problem would be: 1. Get Qz1 and Qz2 scores. 2. Get Mp1 and Mp2 scores. 3. Get FE score. 4. Get TE score. 5. Calculate Qz1+Qz2 Mp1+Mp2 FG = 50% x ------------ + 15% x ----------- + 30% x FE + 5% x TE 2 2 6. Display the final grade FG. An algorithm may also be viewed as a recipe. The manner in which the series of steps in a recipe is written is similar to creating an algorithm. But, it should be noted that an algorithm is more than a recipe. An algorithm has to be exact. An example statement in a recipe would be “add salt to taste”. In an algorithm, this is not acceptable because the statement is subjective and not quantifiable. Everything should be definite. 1.2.3 Coding After having set up the algorithm, the next step is to convert this into a list of instructions in a code or language that the computer can understand and execute. This process is called coding.
  • 4. Chapter 1 6 Example. Algorithm Program The list of instructions that will implement the algorithm can be understood by the computer simply because "it is written in the vocabulary of the programming language and conforms to the grammatical rules of the language."[LEES90] This list of instructions understood by the computer is now called a program. In the example above, we converted our algorithm for computing the final grade to a C program. The scanf statements ask for input from the user while the printf statement displays the output. 1.2.4 Encoding The process of entering the program through a computer terminal directly into computer memory is called encoding. 1.2.5 Running, Testing, and Debugging The fifth step in program development would be to execute or run the program. The program is executed or run on different input data. Testing is the art of creating Get Qz1 and Qz2 scores. Get Mp1 and Mp2 scores. Get FE score. Get TE score. Calculate FG. Display the final grade FG. main() { float fQ1, fQ2; float fMP1, fMP2; float fFE, fTE, fFG; scanf("%f", &fQ1); scanf("%f", &fQ2); scanf("%f", &fMP1); scanf("%f", &fMP2); scanf("%f", &fFE); scanf("%f", &fTE); fFG = 0.50 * ((fQ1 + fQ2)/2) + 0.15 * ((fMP1 + fMP2)/2) + 0.3 * fFE + 0.05 * fTE; printf("FG = %.2fn", fFG); }
  • 5. Introduction to Computer Programming 7 Did you know that... The term bug dates back to an old story about a group of programmers who couldn't figure out what was wrong with their programs, until they opened up the computer and found a moth trapped inside [REGE87] different sets of sample data upon which the program will be run. The programmer must submit the program to as many combinations of test data as possible to anticipate and correct any error that might come out before releasing the program to users. The process of executing a program with test input data and checking the output results against the requirements is referred to as desk checking [PRAT96]. Errors that come out during program execution are termed as bugs. Computer programmers use terms as bug-ridden and buggy to describe a program which is poorly written thus containing a lot of errors. The art of correcting these errors is called debugging. These bugs or errors can be classified into two groups: 1. syntactical or logical errors; and 2. compile or run-time errors. Syntactical errors result from failure to follow the syntax of the language. Syntax refers to the grammatical rules of the language defining its legal constructs. Examples of which are unrecognized instructions, missing punctuation marks and misspelled names. Logical errors are hard to identify. What is erroneous here are the outputs seen onscreen which did not conform to or match the expected results. Such errors arise during the formulation of algorithm or in the coding of the program that implements the algorithm due to the wrong analysis or perhaps wrong approach of the programmer as he tackles the problem given. Compile-time errors halt the compilation of the program. Compilation means translating the program codes into a form that the physical computing machine can understand. Program codes are translated completely so long as their syntax is correct. Once a syntax error is encountered during compilation, this is considered to be a compile-time error. Errors that appear during program execution are called run-time errors. Once a program starts running, it means that the program is already free of syntax errors and compilation has successfully finished. However, it may still have logical errors that may cause the abnormal termination of the program. An example would be dividing a certain number by zero. Another would be the program executing in an endless loop wherein the only way to stop it is to manually stop the execution of the program.
  • 6. Chapter 1 8 1.2.6 Documentation There are three basic types of documentation. The most common type of documentation is the user’s manual. Software usually comes with a user’s manual and it contains information on the software and hardware requirements, installation procedures, and step-by-step instructions on how to use the system. This type of documentation is used by the user of the program. In the process of making sure that the program is error-free, running correctly and efficiently, documentation of the program must be done. The purpose of which is to maintain the relevance and validity of the program. For the next two types of documentation, the process must be continuous. Programs in real-world applications will likely be used for a number of years and will probably require some modification as time passes. Especially in large programs developed for complex projects, there will usually be obscure bugs that do not become apparent until after the program has been placed in use.[LEES90] Such modifications made due to further discovering errors while the program is in use must be documented well. Ten years after the program has been written, someone may want to update it and the first thing he'll do is to look at the documentation of the program to become aware of the details of the program. Good documentation reduces program maintenance efforts and major problem reconstruction. These are the objectives of creating the technical manual and internal documentation. The technical manual is a printed copy of the information regarding how the program was designed and how it was created. Issues involved in choosing the data type or data structure, as well as the algorithm for the solution, are also included. On the other hand, the internal documentation has the same information but these are stored within the program themselves, through the use of comments.