01 - Introduction To Computer Programming

  • July 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View 01 - Introduction To Computer Programming as PDF for free.

More details

  • Words: 708
  • Pages: 3
Computers

• One of the most important inventions of the 20th century • Has become a vital part of our lives

Introduction to Computer Programming

2

Roles of Computers

The Making of an Art! • 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

3

The Making of an Art!

4

Program Planning and Development

The best programmers don’t “just write anything and make it run.”

1. 2. 3. 4. 5. 6.

It’s a matter of putting your heart and mind in developing a masterpiece.

5

Problem Analysis Setting up an algorithm Coding Encoding Running, Testing, & Debugging Documentation

6

1

Problem Analysis

Problem Analysis Example Given the scores for the 3 departmental exams, machine project, final exam, and SARCS (Seatwork, Assignment, Recitation, Case Studies), write a program that will compute for the final grade based on the following computation:

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

40% 30% 15% 15%

Average of 3 departmental exams Final Exam Machine project Seatwork, Assignments, Recitation, Case Studies

7

8

Problem Analysis

Problem Analysis

1. What are we asked to do?

3. Assign names to each input and output Input: Quiz No. 1 Quiz No. 2 Quiz No. 3 Final Exam Machine Project SARCS Grade

Compute the Final Grade

2. What are the given data (inputs) and results that are to be produced (outputs)? Input: Quiz No. 1 Quiz No. 2 Quiz No. 3 Final Exam Machine Project SARCS Grade

Output: Final Grade

Output: Final Grade

- Q1 - Q2 - Q3 - FE - MP - SARC

- FG

4. How do we accomplish our task? FG = 40%

Q1 + Q2 + Q3 3

+ 30% (FE)

+ 15% (MP) + 15% (SARC) 9

Setting Up an Algorithm

10

Coding

Algorithm a list or sequence of steps that solves the given problem

Coding is the process of converting an algorithm into a list of instructions in a code or language that the computer can understand and execute.

Note: The steps should be as detailed as possible.

Example: Step 1. Step 2. Step 3. Step 4. Step 5.

Get Q1, Q2, and Q3 grade Get FE grade Get MP grade Get SARC grade Calculate the FG using the formula Step 6. Display the final grade FG 11

12

2

Coding example

Step 1. Get Q1, Q2, and Q3 grade

Encoding main() { float fQ1, fQ2, fQ3, fFE; float fMP, fSARC; float fFG; scanf(“%f”, scanf(“%f”, scanf(“%f”, scanf(“%f”, scanf(“%f”, scanf(“%f”,

Step 2. Get FE grade Step 3. Get MP grade Step 4. Get SARC grade

&fQ1); &fQ2); &fQ3); &fFE); &fMP); &fSARC);

fFG = 0.40*(fQ1+fQ2+fQ3)/3 + 0.30*FE + 0.15*fMP + 0.15*fSARC;

Step 5. Calculate the FG using the formula Step 6. Display the final grade

The process of entering the program through a computer terminal directly into computer memory is called encoding.

printf(“FG = %.2f\n”, fFG); } 13

14

Running, Testing, and Debugging

Documentation

• These bugs or errors can be classified into two groups:

Basic Types of Documentation: – User’s manual

– syntactical or logical errors; and – compile or run-time errors.



step by step instruction on how to use the program

– Internal Documentation •

Syntactical errors are caused by deviating from grammatical rules of the language.

comments included in program regarding how program was designed and created

– Technical Manual •

Logical errors are caused due to faulty algorithm formulation.

printed details on how the program was designed and created

Reasons for doing documentation:

Compile errors are errors that occur when syntax errors are encountered while translating the program code into a form that the physical computing machine can understand.

1. Ease of understanding different parts of the code. 2. Reduces efforts during program maintenance and problem reconstruction.

Run-Time errors are the effect of logical errors. They appear during the execution of the program. 15

16

Introduction to Computer Programming

3

Related Documents