Homework 2, due September 23, 2010.

Due Thursday, September 23, 2010.
Post Reply
goodwine
Site Admin
Posts: 1596
Joined: Tue Aug 24, 2004 4:54 pm
Location: 376 Fitzpatrick
Contact:

Homework 2, due September 23, 2010.

Post by goodwine »

Be sure to upload all your programs in by replying to the uploads link to Homework 2. Also be sure to print all your programs and submit them with the written part of your homework.

Collaborative Problems:
This homework will ask you to intentionally make a lot of programming mistakes, which will hopefully help you avoid the most common pitfalls. You can combine as many of the questions as possible into single programs, but make sure that whatever you submit addresses each problem. You may exercise your own judgment in this regard, but I would observe that it will usually make it easier for a TA to grade the homeworks if the programs are organized in a manner (with comments) that indicate where exercise is being addressed.

For each question and/or problem, you must both
  • write the general answer; and,
  • illustrate it in a program.
I provide the answer for question 1 as an illustration.
  1. What happens in an algebraic computation when the quotient of two integers is computed?
    • Answer: the quotient is computed and then truncated and the value returned is an integer.

      Part of a complete program that you upload should contain:

      Code: Select all

      c     Problem 1
            print *, 'The quotient 10/3 is ', 10/3
  2. What happens when a real number is divided by an integer?
  3. What happens when an integer is divided by a real number?
  4. Do the same results hold for the previous three questions if the computations are done with variables instead of numbers? For example

    Code: Select all

          integer x,y
          print *, 'x/y =', x/y
    Instead of using the code written right above this, write a program that demonstrates all three and correctly uses implicit data typing.
  5. Repeat the previous problem, but put IMPLICIT NONE as the first statement and properly declare all the variables.
  6. As pointed out in class, programs with variables with names longer than six characters will compile and run. Can a program distinguish between variables that have more than six characters, e.g., will

    Code: Select all

          variable1=3.0
          variable2=2.0
    do what you expect?
  7. What happens when you try to compile a program with variables that are not properly named, e.g., if a variable starts with a number?
  8. Can you compile a program with a variable that starts with a symbol such as "@"?
  9. Print out or copy the following arithmetic expressions.

    Code: Select all

          x = 16.0**4.0*2.0
          x = (2**4/12+3)*(18/(2+4))**5/4
          x = 2/3/4/5*4*3*2+4+3+9/(3+5)**2
          x = 2+3+4**(5/2+3)
    Construct a diagram for each expression like the following figure that indicates the order in which the operations will be performed. Unlike the diagram below, write next to each number that indicates the order in which the computations are performed, what the value is that results from the computation. For example, if A=2, then next to the 2 for the second computation, put a 4.1. Verify the final answer you compute by copying the expressions into a program and printing the answer.
    • Image
Individual Problems:
  1. Write a FORTRAN program that allows a user to input the x and y values of two points in the plane and the x value for a third point. Have the program compute and then print out to the screen the y value for the third point if it is on the line that connects the first two points.
Bill Goodwine, 376 Fitzpatrick
mhart2

Re: Homework 2, due September 23, 2010.

Post by mhart2 »

How do we repeat the individual programming problem from the first week if that homework has not been returned to see what we mistakes we made?
goodwine
Site Admin
Posts: 1596
Joined: Tue Aug 24, 2004 4:54 pm
Location: 376 Fitzpatrick
Contact:

Re: Homework 2, due September 23, 2010.

Post by goodwine »

mhart2 wrote:How do we repeat the individual programming problem from the first week if that homework has not been returned to see what we mistakes we made?
Sorry about that. I deleted that part.
Bill Goodwine, 376 Fitzpatrick
agreen8

Re: Homework 2, due September 23, 2010.

Post by agreen8 »

part 1. problems 1-5
You do not have the required permissions to view the files attached to this post.
agreen8

Re: Homework 2, due September 23, 2010.

Post by agreen8 »

oops.. my fault. i put it in the right place..
vsteger

Re: Homework 2, due September 23, 2010.

Post by vsteger »

Homework 2 upload part 3/3
You do not have the required permissions to view the files attached to this post.
goodwine
Site Admin
Posts: 1596
Joined: Tue Aug 24, 2004 4:54 pm
Location: 376 Fitzpatrick
Contact:

Re: Homework 2, due September 23, 2010.

Post by goodwine »

Someone asked me:
I found that on number 9 of the collaborative problems that FORTRAN truncated the answer to each step of the arithmetic. Should I turn in each step truncated or should I turn in the actual value on a sheet of paper?
It says to print the value that would be calculated, so a complete answer would have the truncated answer. However, since you probably need the right answer along the way, including that won't hurt.
Bill Goodwine, 376 Fitzpatrick
jshudick

Re: Homework 2, due September 23, 2010.

Post by jshudick »

For question 9, do the diagrams need to be done on the computer or can they be done by hand?
goodwine
Site Admin
Posts: 1596
Joined: Tue Aug 24, 2004 4:54 pm
Location: 376 Fitzpatrick
Contact:

Re: Homework 2, due September 23, 2010.

Post by goodwine »

jshudick wrote:For question 9, do the diagrams need to be done on the computer or can they be done by hand?
By hand is fine.
Bill Goodwine, 376 Fitzpatrick
nrivera2

Re: Homework 2, due September 23, 2010.

Post by nrivera2 »

Homework 2
You do not have the required permissions to view the files attached to this post.
nrivera2

Re: Homework 2, due September 23, 2010.

Post by nrivera2 »

Homework 2, problems 6-9 and individual
You do not have the required permissions to view the files attached to this post.
Post Reply

Return to “AME 20214, Homework 2”