1 / 7

Lecture 2

Lecture 2. Programming life cycle. computer piano analogy. Piano + player - computer hardware Musical score/notes - software or program Composer - programmer A music box is set with one melody – similar to a microwave's preset computer chip. Algorithm.

Download Presentation

Lecture 2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 2 Programming life cycle

  2. computer piano analogy • Piano + player - computer hardware • Musical score/notes - software or program • Composer - programmer • A music box is set with one melody – similar to a microwave's preset computer chip

  3. Algorithm • An algorithm is a set of steps to accomplish a task • High level language and source code are synonyms. Examples include C, C++, Pascal, Java, COBOL, Fortran, Python … • All these languages have very specific syntax. This allows a compiler program to read them and translate them into machine code. • Machine code-the final executable file that can be run as an application.

  4. HLL, pseudocode, syntax • All High level Languages (HLL) have similar constructs such as a "while" loop, "if then" statements and others. Therefore a programmer often first writes code in Pseudocode. • Pseudocode- code that almost source code but cannot be run through a compiler since it does not have the correct syntax. • Syntax- the exact proper way a HLL must be written in for a compiler program to work.

  5. Compiler • source code machine code • Source code is stored in a simple text file • machine code is stored in an executable file or an application file. Compiler

  6. Sample pseudocode 2Registration system in BC. • First we will keep all information in two tables (on the hard disk but copied to RAM when the program runs: • The first is a students table that has students� addresses, courses taken or registered for and grades. � • The second is a course database that has the course number, hours, number enrolled and enrollment limit. • Enter all courses that will be offered this semester • If a new student comes to register enter name into student database • For each course a student wants to take • i.If the course is not full, in the course table increment the number enrolled and in the student table enter the course number for that student. • ii.If the course is full inform the student that they would need an overtally.

  7. Sample pseudocode 1average entered grades • prepare the following three variables (a spot in memory to store things): • nstudents- number of grades entered so far, sum-sum of grades so far, avg-average of grades • while entered grade from user is still not negative • nstudents = nstudents+1 • read another grade from user • add grade to sum • avg=sum/nstudents • print avg to the screen

More Related