IT112-Module-1-Topic-1.pdf

Full Transcript

MODULE 1 - PROGRAMMING CYCLE, ALGORITHM & FLOWCHART IT112 - COMPUTER PROGRAMMING 1 DEFINITION OF TERMS ▪ Computer Program ▪ A set of electronic instructions that performs a specific task ▪ Also referred to as software ▪ Written in a specific programming language. ▪ Programming Language ▪...

MODULE 1 - PROGRAMMING CYCLE, ALGORITHM & FLOWCHART IT112 - COMPUTER PROGRAMMING 1 DEFINITION OF TERMS ▪ Computer Program ▪ A set of electronic instructions that performs a specific task ▪ Also referred to as software ▪ Written in a specific programming language. ▪ Programming Language ▪ An artificial language used to write instructions that can be translated into machine language and then executed by a computer ▪ Computer Programming ▪ A process of solving a problem that involves analyzing, coding, testing and maintaining the computer program. THE PROGRAMMING CYCLE ▪ The computer basically is a problem solving tool. ▪ Once it is provided with a valid program, the computer becomes self- operational (requires no human intervention during processing). ▪ To use this effectively, the programmer usually has to follow these well-defined steps: 1. Defining the problem 2. Planning the solution 3. Coding the solution 4. Checking out the program 5. Documentation DEFINING THE PROBLEM ▪ making sure what has to be done or what problem has to be solved ▪ careful analysis of that need should involve both ▪ prospective users of the information; and ▪ one or more trained system designers or programmers ▪ perceive the full nature of the information need and how the computer can be used to respond to it. DEFINING THE PROBLEM Aspects of information that need identification should be determined during this stage of program development includes: INPUT PROCESS OUTPUT or simply called as IPO (Input-Process-Output) information. DEFINING THE PROBLEM Steps to define the problem: 1. Look for keywords which manifests IPO information. For input, keyword is “reads in” For process, keyword is “computes” For output, keyword is “prints” 2. After looking for keyword for each IPO, identify the data that best associates it. For keyword “reads in”, it associates with the data “radius of a circle” For keyword “computes”, it associates with the data “area of a circle” For keyword “prints”, it associates with the data “area of a circle” DEFINING THE PROBLEM (EXAMPLE) Write a program that reads in radius of a circle, computes the area of circle, and then prints the area of circle. I (Input) – radius of a circle P (Process) – area of a circle using the formula A=πr2 O (Output) – area of a circle DEFINING THE PROBLEM (EXAMPLE) Your friend has an assignment that requires them to monitor the room temperature in a given day. The teacher wants the record to be in Celsius; however, the thermometer is broken and only expresses temperatures Fahrenheit. Your friend asks for your help to create a program they can use and gives you the formula: C=(5/9)*(F-32) I (Input) – P (Process) – O (Output) – PRACTICE! ▪ Write a C program to compute the sum of the two given integer values. If the two values are the same, then return triple their sum. ▪ Write a C program to calculate a motorcycle’s average consumption from the given total distance (integer value) traveled (in km) and spent fuel (in liters, float number – 2 decimal point). PLANNING THE SOLUTION ▪ After the problem has been identified with IPO information the next step is to select the best method for solving it. This commonly involves determining the sequence of processing steps. ▪ This step involves 3 methods: 1. Algorithm 2. Flowcharting 3. Selecting the appropriate programing language CODING THE SOLUTION Coding can be written at different levels such as follows: 1. Machine Language ▪ the lowest-level programming language ▪ the only languages understood by computers ▪ a set of symbolic instruction codes that uses binary to represent data and operations ▪ also called also machine code MACHINE LANGUAGE SAMPLE: CODING THE SOLUTION 2. Assembly Language ▪ also known as assembler language (ASM) ▪ any low-level programming language in which there is a very strong correspondence between the program's statements and the architecture's machine code instructions. ▪ Assembly code is converted into executable machine code by a utility program referred to ▪ as an assembler. ▪ The conversion process is referred to as assembly, or assembling the source code. ▪ Because of it’s nature, different hardware have different assembly language approaches. ASM EXAMPLE: x86 addition of two numbers CODING THE SOLUTION 3. High-Level Language (HLL) ▪ a programming language that enables a programmer to write programs that are more or less independent of a particular type of computer. ▪ considered high - level because they are closer to human languages and further from machine languages. ▪ focuses more on the programming logic rather than the underlying hardware components such as memory addressing and register utilization COMPARISON: CHECKING OUT THE PROGRAM ▪ A program seldom executes successfully the first time. ▪ Even the simplest programs contain errors, and even experienced programmers make mistakes. ▪ As computer programs become increasingly complex, more and more of the programmer’s time is spent in program checkout - debugging and testing each new or modified program. ▪ Debugging – is the task of finding program errors (or bugs) and correcting them so that the program runs correctly. ▪ Testing – consists of running the program with input data that simulates, or is a representative sample of the actual data that will be processed by the program. CHECKING OUT THE PROGRAM Types of errors: ▪ Syntax – also known as clerical, is an error in format and mostly occur in the coding or data entry process. ▪ Usually causes the program to not run or run but terminate abnormally ▪ Semantic – also known as logical, is an error when the programmer does not thoroughly understand a phase of the problem to be solved. ▪ In computer programming, a logic error is a bug in a program that causes it to operate incorrectly, but not to terminate abnormally. ▪ A logic error produces unintended or undesired output or other behavior, although it may not immediately be recognized as such. DOCUMENTATION ▪ After a program has been fully tested and implemented, the programmer must write up the full specification for all users called User Manual. ▪ If all the pertinent data is contained within the documentation package, then the program can be run and modified without requiring the original programmer’s assistance. END OF MODULE 1 - TOPIC 1

Use Quizgecko on...
Browser
Browser