Computer Programming Objectives Program and Programming Algorithms Programs
Computer Programming
Objectives Program and Programming Algorithms & Programs Software Life Cycle Computer Language Generations Flowchart
Program and Programming
Program and Programming Program: • A set of instruction written in a programming language that a computer can execute so that the machine acts in a predetermined way. • Program solves a problem • Before writing a program: – Have a thorough understanding of the problem – Carefully plan an approach for solving it. Programming: The Process of providing instructions to the computer that tells the processor what to do. 4
Algorithms and Programs
Algorithms and Programs An Algorithm is a solution to a problem that is independent of any programming language. While A program is an algorithm expressed using a specific set of instructions from any programming language. 6
Algorithm Example • Maximum of two numbers Steps: 1. Read/input two numbers 2. Compare two numbers 3. Print the Greater number • Average of three numbers Steps: 1. Read/input three numbers 2. Add three numbers 3. divide the sum by 3. 4. Print the result of division 7
Software Life Cycle
Software Life Cycle What Requirements Gathering, Problem definition Analysis and Design (Programming techniques) How Coding Do it Testing Test Use Implementation and Maintenance 9
Computer Language Generations
Computer Language generations Machine language Assembly languages High-level languages Very high-level languages Natural languages 11
Machine Language Programs and memory locations are written in strings of 0 s and 1 s. Problems with machine languages n n Programs are difficult to write and debug Each computer has its own machine language 12
Assembly Languages n n Use names rather than binary addresses for memory locations. For example, A for add, C for compare, etc. Require an assembler to translate the program into machine language. Still used for programming chips and writing utility programs 13
High-Level Languages Transformed programming n n Programmers could focus on solving problems rather than manipulating hardware Programs could be written and debugged much more quickly Requires a compiler to convert the statements into machine language n Each computer has its own version of a compiler for each language. 14
Very High-Level Languages Also called fourth-generation languages (4 GLs) Considered nonprocedural languages n n The programmer specifies the desired results, and the language develops the solution Programmers can be about 10 times more productive using a fourth-generation language than a third-generation language 15
Natural Languages Resemble written or spoken English n Programs can be written in a natural syntax, rather than in the syntax rules of a programming language The language translates the instructions into code the computer can execute 16
Major Programming Languages FORTRAN COBOL BASIC Visual Basic C Java 17
Object-Oriented Languages C++ Java C# Visual Basic 18
- Slides: 18