210 likes | 558 Views
Computer Programming (BCT 1113). Introduction To Programming Computer Programming Concept Problem Solving Flowchart Structure Programming Design Implementation Documentation Testing and Debugging. Objectives. Understand Computer Programming Concept Problem Solving Design Flowchart
E N D
Computer Programming (BCT 1113) Introduction To Programming Computer Programming Concept Problem Solving Flowchart Structure Programming Design Implementation Documentation Testing and Debugging
Objectives • Understand Computer Programming Concept • Problem Solving • Design Flowchart • Structure Programming Design • Implementation of programming • Documentation in programming • Testing and Debugging programming
Why learn programming? • To be a creator - Programming is like having access to the absolute best set of legos in the world in almost unlimited qualities • Automate Away Daily Drudgery - Programmers are famous for being lazy--in fact, being lazy is one reason people are drawn to programming. After all, why do something routine and repetitive when you could have your computer do it for you? • Improve Your Computer Literacy and Know the Answer to the "Why" Questions - People are often frustrated by technology when it fails. Although operating systems such as Windows have become much more stable, there are still many security holes exploited every day. For a non-programmer, these issues are mysteries: the machine that never makes mistakes is full of problems, and who knows why?
How to learn programming? • Look at the Example Code • Don't Just Read Example Code--Run It • Write your Own Code as Soon as Possible • Learn to Use a Debugger • Seek out More Sources
Types of programming language • Procedural programming language – Fortran, BASIC • Structural programming language – C, ADA, Pascal • Object oriented programming language – JAVA, VB, C#
History of programming language • Before 1940: The Jacquard loom, invented in 1801, used holes in punched cards to represent sewing loom arm movements in order to generate decorative patterns automatically. • 1940: first recognizably modern, electrically powered computers were created • 1950: 1960 – FORTRAN, LISP, COBOL • 1967 – 1978: establishing fundamental paradigm – Simula, C, Prolog, • The 1980s: consolidation, modules, performance – ADA, C++, Perl • The 1990s: the Internet age – PYTHON, VB, JAVA, PHP, ASP
Programming • Program: self-contained set of instructions used to operate a computer to produce a specific result • Also called software • Programming: the process of writing a program, or software
Programming • Machine language programs, also called executables, consist of binary instructions • Each instruction has two parts: • Instruction part: the operation to be performed; also called an opcode • Address part: memory address of the data to be used • Each class of computer has its own particular machine language
Programming structure • Algorithm: the step-by-step sequence of instructions that describe how the data is to be processed to produce the desired output • Programming: the translation of the selected algorithm into a language the computer can use • Pseudocode: English-like phrases used to describe the algorithm • Formula: description of a mathematical equation • Flowchart: diagram showing the flow of instructions in an algorithm • Flowcharts use special symbols
Flowchart: example Figure 1.12 Flowchart for calculating the average of three numbers.
Pseudo code: example Read NUMBER1, NUMBER2, NUMBER3 Compute AVERAGE as ((NUMBER1+NUMBER2+NUMBER3)/3) Write (Display) AVERAGE
Implementation • Write a program that could display following information #include <iostream> using namespace std; int main() { cout << “Umar"; cout << "\n123 JalanCempaka"; cout << "\nChukai, Kemaman"; cin.ignore(); // this line is optional, it is used // to keep the program from ending on Microsoft // systems/compilers so the user can see the output return 0; }
Process of Writing a Program • Identify problems – requirements, specification • Design a solution – pseudo code, flowchart • Program • Code - translating the design into an actual program, written in some form of programming language • Compile - process of turning the program written in some programming language into the instructions made up of 0's and 1's that the computer can actually follow • Debug - task of looking at the original program, identifying the mistakes, correcting the code and recompiling it
Documentation in Programming /* my second program in C++ with more comments */ #include <iostream> using namespace std; int main () { cout << "Hello World! "; // prints Hello World! cout << "I'm a C++ program"; // prints I'm a C++ program return 0; }
Testing & Debugging • All written program must be tested to ensure it is correctly run and suit requirements. • Debugging is the process of locating and fixing or bypassing bugs (errors) in computer program code or the engineering of a hardware device. • To debug a program or hardware device is to start with a problem, isolate the source of the problem, and then fix it
Common programming mistakes • Starting to write the program before fully understanding the requirements and the algorithm to be used • Undeclared variables • Uninitialized variables • Using a single equal sign to check equality • Undeclared Functions • Extra Semicolons • Misusing the && and || operators
REFERENCES http://www.cprogramming.com/whyprogram.html http://www.giac.org/cissp-papers/97.pdf http://www.cs.bham.ac.uk/~rxb/java/intro/2programming.html