Lecture Introduction To Computer Programming PDF
Document Details
Dr. Joan P. Lazaro, PCpE
Tags
Summary
This lecture introduces computer programming concepts and describes the program development life cycle (PDLC) including problem analysis, design, coding, debugging, and maintenance. It also covers important topics like flowcharting and control structures essential for a better understanding of computer programming.
Full Transcript
INTRODUCTION TO COMPUTER PROGRAMMING Prepared By: Dr. Joan P. Lazaro, PCpE What is Programming? Programming is instructing a computer to do something for you with the help of a programming language. The role of a programming language can be described in two ways: Techni...
INTRODUCTION TO COMPUTER PROGRAMMING Prepared By: Dr. Joan P. Lazaro, PCpE What is Programming? Programming is instructing a computer to do something for you with the help of a programming language. The role of a programming language can be described in two ways: Technical: It is a means for instructing a computer to perform tasks. Conceptual: It is a framework within which we organize our ideas about things and processes. What is Programming? In programming we deal with two kind of things: Data that represents “objects” we want to manipulate. Procedures which are “descriptions” or “rules” that define how to manipulate data. The Program Development Life Cycle (PDLC) Creating new programs is called program development. The process associated with creating successful applications programs is called the program development life cycle (PDLC). The following are the steps for PDLC: Problem Analysis Program Design Program Coding Program Debugging and Testing Program Maintenance Problem Analysis Applications software development normally begins with reviewing the program specifications indicating what the new system should do. During this stage, the systems analyst and programmer review the specifications and possibly talk with users in order to fully understand what the software should do. Program Design During program design, the specifications are used to express the algorithm needed to solve the problem, usually in the form of any number of program design tools. Program Design Tools are planning tools. Many such tools have been developed, but two of the most important are program flowcharts, and pseudocode. Program Design Program flowcharts use geometric symbols and familiar relational operators to provide a graphic display of the sequence of steps involved in a program. The steps in a flowchart follow each other in the same logical sequence as their corresponding program statements will follow in a program. Program Design Pseudocode uses English-like statements in place of the graphic symbols of the flowchart. Unlike a flowchart, pseudocode is easy to modify and can be embedded into a program as comments. No standard set of rules exists for writing pseudocode, although a number of conventions have been developed. Program Design Control Structure – a control structure is a series of instructions that control the logical order in which the program instructions are executed. A sequence control structure is simply a series of procedures that follow one another. The selection (if-then-else) control structure involves a choice: if a certain condition is true, then follow one procedure; else, if false, follow another. A loop (iteration) control structure is an operation that repeats until a certain condition is met. Program Coding Coding is the actual process of creating the program in a programming language. One of the first steps in the coding process is deciding which programming language to use. Languages for specific applications are often chosen with respect to such criteria as suitability, compatibility with other applications, organizational standards, programmer availability, portability, and speed. Program Debugging & Testing Debugging is the process of making sure a program is free of errors, or “bugs.” Preliminary debugging begins after the program has been entered into the computer system. Rarely is a program error-free the first time it runs. Two common types of errors are syntax errors and logic errors. A syntax error occurs when the programmer has not followed the rules of the language. A logic error, or execution-time error, results when the command syntax is correct but the program is producing incorrect results. Program Maintenance Virtually every program, if it is to last a long time, requires on-going maintenance. Program maintenance is the process of updating software so that it continues to be useful. It is a costly process, but can be used to extend the life of a program. Flowcharting The flowchart is a means of visually presenting the flow of data through an information processing systems, the operations performed within the system and the sequence in which they are performed. In this topic, we shall concern ourselves with the program flowchart, which describes what operations (and in what sequence) are required to solve a given programming problem. Flowcharting Common Symbols used in Flowcharting Flowcharting Common Symbols used in Flowcharting Flowcharting Sequence Control Structure - is used to show a single action or one action followed by another. Flowcharting Example: Create a flowchart that will input two integers and display the sum. Create a flowchart that will input the temperature in Fahrenheit and display the equivalent value in Celsius. NOTE: C = (5/9) * (F – 32) Create a flowchart that will input customer’s money and his bill and compute for the change. Flowcharting Selection Control Structure – is used to tell the program which action to take based on a certain condition. Flowcharting Example: Create a flowchart that will input a student grade and determine if the student is passed or failed. Assume 75 and above is the passing mark. Create a flowchart that will input the employee’s gross salary and display the net salary. Assume 10% tax will be deducted if the gross salary is greater than 10,000, otherwise 5%. Create a flowchart that will determine if the input number is “ODD” or “EVEN” Flowcharting Repetition Control Structure – also called looping or iteration is used when a set of actions is to be performed repeatedly. Flowcharting Example: Create a flowchart that will display the numbers from 1 to 10. Create a flowchart that will compute for the Simple Interest 5 times. Assume: Interest = Principal Value * Rate * Time Create a flowchart that will input 5 integers and will determine the sum and average.