1 / 16

CS1001 Lecture 13

CS1001 Lecture 13. Mid-Term Review Things You Absolutely Must Know. Program Parts. Header Specification Description Variable Listing etc Input Computation Display END PROGRAM. Program statement & Specification. Program Statements PROGRAM ProgramName END PROGRAM ProgramName

gustavoc
Download Presentation

CS1001 Lecture 13

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. CS1001 Lecture 13 • Mid-Term Review • Things You Absolutely Must Know

  2. Program Parts Header Specification Description Variable Listing etc Input Computation Display END PROGRAM

  3. Program statement & Specification • Program Statements PROGRAM ProgramName END PROGRAM ProgramName • Specification (Data) IMPLICIT NONE REAL :: Variable REAL, PARAMETER :: CONS = 5.789 INTEGER :: Variable INTEGER, PARAMETER :: Constant = 1 CHARACTER :: Variable etc.

  4. Data Naming • Variables may be mixed case, initial capital and descriptive: • InputTemperature • StepSize • Follow some naming convention, e.g., Hungarian notation • rVariable for REAL data types • iVariable for INTEGER data types • bVariable for LOGICAL data types • etc.

  5. Specification (Initialization) • REAL initialized automatically to 0.0 • INTEGER initialized automatically to 0 • CHARACTER manually initialized: • cQuit = “c” • LOGICAL manually initialized: • bValid = .FALSE.

  6. User Input • User is prompted with a PRINT statement: • PRINT *, “Enter a number from 1 to 10:” • User inputs data read by a READ statement: • READ *, iGuess • User inputs should be validated for range, with correction permitted

  7. Computation & Program flow • Algorithms are procedures developed to perform some desired operation • Repetitive operations can be performed within a loop • Branching (depending on logical expressions or CASE) can be used to perform different procedures

  8. IF Structures • Perform procedure if condition is T or skip: IF (condition) THEN procedure END IF

  9. IF ELSE Structures • Perform one procedure if condition T otherwise do second procedure: IF (condition) THEN first procedure ELSE second procedure END IF

  10. IF ELSE IF Structures • Perform one procedure if condition T otherwise do second procedure if second condition true, else do: IF (condition one) THEN procedure one ELSE IF (condition two) THEN procedure two ELSE procedure three END IF

  11. DO Loops • Counter repetition: DO ControlVar = InitVal, FinalVal, Step statements END DO • DO until condition is TRUE (Pretest, Posttest, Test in the middle): DO statements IF (condition) EXIT statements END DO

  12. Output Display • Results are displayed on the screen using PRINT statements PRINT *, “The answer is: ” , iNumberOut

  13. Statement Summary • PROGRAM, END PROGRAM • IMPLICIT NONE • REAL, INTEGER, CHARACTER, LOGICAL, PARAMETER • PRINT, READ • IF, THEN, ELSE IF, ELSE, END IF • DO, EXIT, END DO

  14. Nature of the Test • 10 questions total • Simple one or two line questions worth 5 points each. E.g., Declare a real variable and initialize to 27.356 REAL :: rSomeVariable rSomeVariable = 27.356 • More complex questions worth 15 points each Write an IF structure to validate a range of inputs • Multiple choice questions

  15. Software • What You Should Bring • One 8.5 x 11-inch piece of paper with notes on both sides • Test is closed notes and closed book • Pencils • Extra paper if needed

  16. Preparation • READ THE BOOK • Review your notes and lecture material • Review your homework and quizzes • Relax, get a good night’s sleep • Write to us if you have any questions

More Related