Lecture-03.1

# Lecture-03.1 - CSE 1540.03 Week 3.2 (no Week 3.1) January...

This preview shows pages 1–2. Sign up to view the full content.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CSE 1540.03 Week 3.2 (no Week 3.1) January 18, 2012 Selection if ( condition ) then statements end if if ( condition ) then statements else statements end if Examples: if (n .LT. 0) then n = -n end if if (mod(n,2) .EQ. 0) then print*, n, " is an even number." end if if (0 .LE. x .and. x .LE. 100) then print*, "in the interval [0,100]" else print*, "outside the interval [0,100]" end if Cascaded if-then-else (special variation of if-then-else) if ( condition #1 ) then statements alternative #1 else if ( condition #2 ) then statements alternative #2 ... else if ( condition #n ) then statements alternative #n else ) optional statements ) end if Example Given a numerical grade (0-100), transform it to a letter grade. 80-100 A draw number line 70-79 B 60-69 C 50-59 D 0-49 F if (mark .GE. 80) then print*, "A" else if (mark .GE. 70) then print*, "B" else if (mark .GE. 60) then print*, "C" else if (mark .GE. 50) then print*, "D" else print*, "F" end if CSE 1540 Week 3.2 January 18, 2012 page 1 of 2 to check grade is valid, add...
View Full Document

## This note was uploaded on 02/13/2012 for the course CSE 1540 taught by Professor Hofbauer during the Winter '12 term at York University.

### Page1 / 2

Lecture-03.1 - CSE 1540.03 Week 3.2 (no Week 3.1) January...

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

View Full Document
Ask a homework question - tutors are online