CSE 1540.03
March 24, 2014
Week 11.1
Given an array of integers, find the length of the longest increasing
sequence.
23135468933246
Problem:
Given an array of integers, remove duplicate values.
subroutine removeDups (n, m, ar)
integer
integer
logical
Prob

CSE 1540.03
March 5, 2014
Week 8.2.2
program Function
implicit none
integer fcn, a, b, c, d, e
a = 5
b = 10
c = 15
d = 2
e = a + fcn(b,c)*2
print*, e
print*, a + fcn(b,c)*2
end
Program Building Blocks
Program Units
- main program
- subprograms: 1) subrout

LAB 11
Objectives
Random Numbers
Distribution
Fortran-generated Charts
TASK
Given an integer N and a range [min,max); i.e. min included and max excluded, we
like to generate N randomly-selected real numbers in that range. The selection can be
done eith

Guidelines for the Final Exam - COSC1540.03M
1. General
Bring a calculator, a crib sheet (8.5x11, both sides) and a photo ID.
You may use a pen or a pencil.
2. Mark Distribution
Q1: 25 points
Q2: 15 points
Q3: 15 points
Q4: 15 points
Q5: 30 points

Part A
[20 marks]
1. Refer to the program below:
program Pt2p1
implicit none
character*80 t1, t2
integer j, k, b(20)/20*0/
1 format(A)
2 format(20I4)
print*, "Type some text, hit enter, type more text, hit enter"
read 1, t1, t2
call rout1 (t1, t2, b, k)
p

CSE 1540.03
January 15, 2014
Week 2.2
Arithmetic Expressions in Fortran
- Convert two-dimensional mathematical notation to
one-dimensional computer notation
Assignment Statement
variable = expression
Example:
b b 2 4ac
2a
Examples:
i=1
the two most commo

York University
Faculty of Pure and Applied Science
Department of Computer Science
COSC1540.03A - Computer Use in Science
Test 1
Wednesday, October 20th, 2004
Instructions:
1.
This is an in class examination, therefore examination rules are in effect
2.
F

OSC1540 - W99 - MIDTERM
QUESTION #1 < 5 points >
The following Fortran program inputs a number a and computes and outputs a
second number r. To understand the algorithm, we construct a trace table that
shows the values, in terms of a, of three program var

LAB #5
Objectives
Practice more IF statements and loops
Learn about strings
Part A
Tasks
1. Type the following program exactly as shown:
2. program Lab5A
3. implicit none
4. ! This program introduces Fortran string handling capabilities
5.
6. character*

CSE 1540.03
January 13, 2014
Week 2.1
Read:
Chapter 3 and 4 of the textbook.
the game of "musical buckets"
Prerequisite for success in Computer Programming:
Donald Knuth (perhaps the world's foremost Computer Scientist) put it
best in a keynote address f

CSE 1540.03
March 5, 2014
Week 8.2.1
program sum
implicit none
real sum, term, x
integer i
print*, "Enter x."
read*, x
Summing Series
Google: "Taylor Series" (see Wikipedia entry)
Consider the following series:
e x 1 x
x 2 x3
xi
1 i
2! 3!
i!
Sketch of a

York University - Faculty of Pure and Applied Science
Department of Computer Science
Sample for TEST #1
COSC1540 / HR
This is a closed book, 90-minute test. Fill in your personal data below and wait.
You may use pen or pencil.
Once the test starts, verify

York University - Faculty of Pure and Applied Science
Department of Computer Science
Sample for TEST #2
COSC1540 / HR
This is a closed book, 50-minute test. Fill in your personal data below and wait.
You may use pen or pencil but answers written in pencil

CSE 1540.03
January 22, 2014
Week 3.2
end
Question: Validate and handle linear case
You can measure a programmer's perspective by noting his (or her)
attitude to the continuing vitality of FORTRAN
Alan Perlis
It is easier to write an incorrect program tha

Lab 6
Objectives
Review loops and selection
Develop an algorithm and implement it
Review and apply built-in string functions and operators
Store data in a one-dimensional array and retrieve information from an array
Task
We want to write a program to prod

LAB 9
Objectives
Structured Problem-Solving
Functions and Subroutines
Date Validation & Conversion
Given a date like 20/2/2002, we like to convert it to: Wed. Feb 20, 2002. The process
involves validating the input to ensure it has the proper format and t

CSE 1540.03
January 20, 2014
Week 3.1
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

LAB 7
Objectives
Explore Numerical Methods
Handle non-closed-form functions
Realize the limitation of the single-program approach
Task-A: Charting an Infinite Series
Some functions have no closed-form formula that computes y at a given x in terms of
st

LAB 8
Objectives
Delegate to functions and subroutines
Use the SLATEC Library
Task-A: Tabulate the Bessel Function
This is identical to what we did in Lab7, namely, tabulate the Bessel function of the
first kind of order 1 in the range [0,10], except we

CSE 1540.03
January 6, 2014
Week #1.1
Why learn Computer Programming?
why learn to play a musical instrument vs. playing a CD or ipod?
why learn to cook vs. eating at a restaurant?
why learn to sew vs. buying clothes?
Computer-based problem solving in Sci

LAB #1
Objectives
The Development Environment
This Lab enables you to set up the Fortran development environment that you will be
using to write, compile, and run Fortran programs. You can create this environment in
one of the academic labs on campus or

LAB 10
Objectives
Structured Problem-Solving
Representing Functions as Arrays
Searching and Sorting Parallel Arrays
Planetary Motion
A scientist is tracking the position of a planet relative to a coordinate system whose
origin is at the Sun and whose a

LAB #2
Objectives
To become familiar with the development cycle
Introduce the Fortran programming language
Tasks
1. Set up the development environment as explained in Lab1 (ending with an editor window
and a DOS window).
2. Type the following program in t

CSE 1540.03
January 27, 2014
Week 4.1
Example:
Add a loop to the temperature conversion example.
Given a list of temperatures terminated by -1000
Iteration
1. while loop
do while (condition)
statements
end do
2. loop with exit
do
statements
if (condition)