Chapter3_mod - ComputerProgramming usingFortran77...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
Computer Programming using Fortran 77 Chapter 3 - Selective Execution
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Selective Execution Basic control structures of all programming  languages 1) Seqeunce (Ch 2) 2) Selection  (Ch 3) 3) Repetition (Ch 4)
Background image of page 2
Selective Execution In chapter 2 we used sequential statements but, this  is not strong enough to support all of the  requirements of our programs Example pollution index --------------- if pollution > 50    display – hazardous Otherwise    display - safe
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Simple Logical Expressions: Relational Expression Syntax : expression 1  relational operator  expression2 Relational operator  ==> .LT., .GT., .EQ., .LE., .GE., .NE. Use . . since x.eq.y is not xeqy - the var Example a = 2.0, b = 1.0, c = 3.0 b ** 2 .GE. 4.0 * a * c 1.0 ** 2 .GE. 4.0 * 2.0 * 3.0 1.0 .GE. 24.0 .FALSE.
Background image of page 4
Simple Logical Expressions: Relational Expression Example a = 100.0, b = 15, c = 2, d = 15 sqrt(a) + 15 .EQ. (5 + (b * c) + d) / 2 sqrt(100.0) + 15 .EQ. (5 + (15 * 2) + 15) / 2 10 + 15 .EQ. (5 + 30 + 15) / 2 25 .EQ. 50 / 2 25 .EQ. 25 .TRUE.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Simple Logical Expressions: Relational Expression Letters in alpha order and numbers are in ascending  order Example: 'A' .LT. 'F’ .TRUE. Example  'M' .GT. 'Z’ .FALSE. For strings use the 1st not equal char of each to compare 'CAT' .LT. 'DOG’ .TRUE. 'HOUSE' .GT. 'HOME’  .TRUE.
Background image of page 6
Logical Expressions Logical op: .NOT., .AND., .OR., .EQV.,.NEQV. Rules, where P is a logical expression .NOT. P ==> negate P P .AND. Q ==> only true if both P and Q are true P .OR. Q ==> TRUE if either P and/or Q is true P .EQV. Q ==> TRUE if both P and Q are the same P .NEQV. Q ==> TRUE if P and Q are not the same Truth table - NOT -----------------------     P  .NOT. P --------------------- .TRUE.     .FALSE. .FALSE.    .TRUE.
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Compound Expressions Truth table – NEQV      P            Q         P .NEQV. Q ----------------------------------.TRUE.   .TRUE.     .FALSE. .TRUE.    .FALSE.    .TRUE. .FALSE.   .TRUE.     .TRUE. .FALSE.   .FALSE.    .FALSE. Truth table – OR       Q      P .OR. Q ------------------------------- .TRUE.    .TRUE.    .TRUE. .TRUE.    .FALSE.   .TRUE.
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/18/2011 for the course CMPS 301 taught by Professor Staff during the Fall '08 term at University of Louisiana at Lafayette.

Page1 / 26

Chapter3_mod - ComputerProgramming usingFortran77...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online