Introduction to Programming Lecture 1 Prof Rommel Anthony
- Slides: 23
Introduction to Programming <Lecture 1> Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2014
Basic Components of a Computer � Computer: machine that performs different tasks according to specific instructions. � It has two major components: � Hardware: composed of electronic and mechanical parts � Software: data, and computer programs Rommel AB Palomino - UDC Spring 2014
Hardware Rommel AB Palomino - UDC Spring 2014
Software Types of Computer Programs: � Operating Systems: Windows, Linux, Solaris � Application Programs: Word, Games, Browsers � Compilers: Translate high level programming languages into machine language Rommel AB Palomino - UDC Spring 2014
Programming Languages � What is a Programming Language? � Express human instructions to computers � Each language has its own syntax � Languages evolved over time. There exist five different programming languages generations. Rommel AB Palomino - UDC Spring 2014
Interpreted vs. Compiled Language � Interpreted: Source code is directly executed at runtime by the interpreter. � Compiled: source code goes to the compiler and creates object code or machine code. Then it is executed in the host CPU. Rommel AB Palomino - UDC Spring 2014
Interpreted vs. Compiled Language Compiled Interpreted • Easy to develop � Needs compilation every time you change the code. • Easy to debug � Hard to debug • Slower to � Compiled language is execute because faster because source code is reduced to directly executed machine code, and then is executed. (“interpreted”) at runtime Rommel AB Palomino - UDC Spring 2014
Generation Languages � Human Sixth Generation: ? ? ? 5 GL or Fifth Generation: use of constraints rather than an algorithm. Comp. solves problem w/o prog Use in AI research such as Pro. Log. 4 GL or Forth Generation: reduce programming effort, developing time, and cost. 3 GL or Third Generation: more programmer frien High level lang. such as C, C++, Java. � Machine 2 GL or Second Generation: Assembly languages push ebx / mov ebx, 1 / dec ebx 1 GL or First Generation: Machine Language (011010110000011) Rommel AB Palomino - UDC Spring 2014
Program Development Life Cycle � The process of developing a software, according to the desired needs of a user, by following a basic set of interrelated procedures. Rommel AB Palomino - UDC Spring 2014
Tasks of Program Development Problem Definition Maintenance Problem Analysis Testing & Debugging Algorithm design and representatio n Coding Rommel AB Palomino - UDC Spring 2014
Tasks of Program Development Problem Definition Maintenance Problem Analysis Testing & Debugging Algorithm design and representatio n Coding • Define clearly the problem in terms of their inputs, outputs and constraints. • A clearly defined problem is half the solution. • This step is very critical for success of the completion of the program. Problem Example: “Create a Program that will give the sum of consecutives numbers from 0 to a determined number” • Invest a significant portion of your time in this phase! Rommel AB Palomino - UDC Spring 2014
Tasks of Program Development Problem Definition Maintenance Problem Analysis Testing & Debugging Algorithm design and representatio n • Once identified the problem, we should find the most effective and simplest solution. • Divide and Conquer: Break problem into smaller and simple sub-problems Problem Example: “Create a Program that will give the sum of consecutives numbers from 0 to a determined number” Input: certain natural number (n) Output: sum of consecutive natural numbers from 0 to n Coding Rommel AB Palomino - UDC Spring 2014
Tasks of Program Development • After doing the analysis, we need to design our proposed solution. Problem Definition Problem Analysis Maintenance Algorithm Design and Representatio n Testing & Debugging Coding • The solution has to be expressed in a step-by-step manner, so the computer will understand it: Algorithm. • Ways of representing it: • Human Language: flowchart • Pseudocode: human lang/prog. lang. • Design techniques: • Modular Programming • Top-Down Design • Structured Programming Rommel AB Palomino - UDC Spring 2014
Pseudocode Problem Example: “Create a Program that will give the sum of consecutives natural numbers from 0 to a determined number” 1. 2. 3. 4. Get number “n” Set count to 0 Set sum to 0 While count is less than or equal to “n“ do � � 5. Add count value to sum Increment count by 1 Return sum Rommel AB Palomino - UDC Spring 2014
Flowchart Process Data Con d Process: represents process of executing an or group of operations that results in a change of value, form or location of information. i. e. : Add 1 to X Sum = sum + 1 Data: Input/output. i. e. : Read N Get N Display X Conditional: Yes/No questions. It has two outputs, one for Yes, and one for No. Rommel AB Palomino - UDC Spring 2014
Flowchart Flowline symbol: Represents the flow of information or the correct sequence of steps in the flowchart. Connector: Connects parts of flowcharts. Terminal Symbol/Terminator: Represents the start or end point of a flowchart. Rommel AB Palomino - UDC Spring 2014
Flowchart Problem Example: “Create a Program that will give the sum of consecutives natural numbers from 0 to a determined number” Start Read n count = 0 sum = 0 count<=n? no yes sum = sum + count = count- + 1 Spring 2014 Rommel AB Palomino UDC Print sum End
Tasks of Program Development Start Problem Definition Read Maintenance n Problem Analysis count = 0 sum = 0 Testing &count<=n? Debugging yes sum = sum + count Coding count = count + 1 no • Algorithm ready! • Process of translate it into computer instructions. • Each prog. language has its own syntax. • Actual software. int n = 5; // let’s pretend we are Print sum Algorithm Design and Representation reading int sum =0, count = 0; while( count <= n ){ sum = sum + count; count = count + 1; } Rommel AB Palomino - UDC System. out. println(sum); Spring 2014 End
Tasks of Program Development Problem Definition Maintenance Problem Analysis Testing & Debugging Algorithm Design and Representatio n Coding • Don’t expect your program works the first time! • Debugging: finding errors (bugs) in your program and fix them. • Two error types: • Compile-time: before running your program. Syntax errors. • Runtime: occurs when you are running your program Compile-time error: int n = 0 Runtime error: ero! z int n = 0; y b n o ivisi int x = 5/n; D Rommel AB Palomino - UDC Spring 2014
Tasks of Program Development Problem Definition Maintenance Problem Analysis Testing & Debugging Algorithm Design and Representatio n Coding Testing: process of validation of the program. Three major types: • Unit testing: test basic units of software • Integration testing: tests two or more tested units • System testing: based on functional/requirement specification Is my program really doing what it was required to do? Look back into your requirements, and your problem definition! Formulate basic tests. i. e. entering the min and max values for Rommel AB Palomino - UDC Spring 2014 parameters.
Tasks of Program Development Problem Definition Problem Analysis Maintenance What if your requirements change? Maintenance: • Updating correcting the more What if yourand boss wants toofadd program for to changing conditions or functionality your program? newly discovered bugs. Should I start all over again from scratch? NO!!!! … as long as you do all your previous steps correctly Algorithm Design and Representatio n Testing & Debugging Coding Rommel AB Palomino - UDC Spring 2014
Exercise � Write a program that can calculate the factorial of a given number “n”. Rommel AB Palomino - UDC Spring 2014
Questions? Rommel AB Palomino - UDC Spring 2014
- Muziek uit oude rommel
- 01:640:244 lecture notes - lecture 15: plat, idah, farad
- C programming lecture
- Perbedaan linear programming dan integer programming
- Greedy vs dynamic programming
- System programming definition
- Integer programming vs linear programming
- Perbedaan linear programming dan integer programming
- Introduction to biochemistry lecture notes
- Introduction to psychology lecture
- Introduction to algorithms lecture notes
- Introduction texte argumentatif exemple
- Introduction to server side programming
- Java introduction to problem solving and programming
- Introduction to programming languages
- Daniel liang introduction to java programming
- An introduction to parallel programming peter pacheco
- Introduction to visual basic programming
- Plc stand for
- Java introduction to problem solving and programming
- Introduction to windows programming
- Introduction to programming
- Csc 102 pdf
- A web based introduction to programming