Checking variables

  1. Write a program which takes in a number from the keyboard and checks its size. If the number is less than 100, the program should print on screen "That is small", and if greater than or equal to 100 print something else appropriate. Enclose the code in a loop, so you can enter several numbers one after another.

  2. Reconsider the quadratic equation program and use an IF THEN statement to return a message that the discriminant is negative and therefore there are no real roots.

    When you have finished or have difficulties compare it to the program quad2.f

  3. Using the last array excerise program and modify it such that it sorts the numbers using the bubble sort method . You should end up with the smallest at the beginning of the list , the largest at the end.

    The bubble sort method - compare the first and second values switch them if they are out of order. The second and third are treated in the same way, and so on. Until a complete pass of the numbers has been done. The numbers are not yet sorted so start another pass. The number of passes requires to ensure sorting will be one less than the number of numbers to be sorted.


Now return to the Introduction to FORTRAN Programming