Sample Programs used in the course

  1. Summing a series up to n terms
  2. Find the n-th 235 number
  3. Version 1 of Bubble sort
  4. Version 2 of Bubble sort
  5. Reversing a number
  6. 2-d array- finding row with max sum
  7. Using a Function to get input within bounds
  8. Version 1 of Knight's walk on Chessboard
  9. Version 2 of Knight's walk on Chessboard
  10. Binary to Decimal conversion
  11. Hexadecimal to Decimal conversion
  12. 3 simple demos using PGPLOT (x^2, sin(x)/x, ...)
  13. Knight's tour using PGPLOT
  14. Here is the code series1.f90 and series2.f90 for the example on passing functions as arguments. To compile, do
    f90 -o series series1.f90 series2.f90
  15. Here is the code 101mod.f90 defining cs101student derived type and 101sort.f90 for sorting and 101main.f90 the main program for calling sort by various criteria. A sample data file 101data.lst is here. To compile, do
    f90 -o 101test 101mod.f90 101sort.f90 101main.f90
  16. Here is the code gui.f90 (GUI module) and the main.f90 used to set up buttons with a sample gui.cfg file. To compile use this file mypgcompile (save this in mypgcompile) and do the following:
    chmod +x mypgcompile
    ./mypgcompile -o guitest gui.f90 main.f90
  17. Here is the code ngui.f90 (new GUI module) and the guiread.f90 used to for INPUT buttons with a sample guiread.cfg file. To compile use this file mypgcompile (save this in mypgcompile) and do the following:
    chmod +x mypgcompile
    ./mypgcompile -o guiread ngui.f90 guiread.f90
  18. Here is the code for pointers. The file simple1.f90 shows how to create lists simple2.f90 shows how to delete elements, and llist.f90 is from Chapman and reads in a list of real numbers from a file.
  19. code for generating permutations perm.f90
  20. Recursive function for fib and fact are defined in fact.f90 and the file qsort.f90 implements quicksort of an array.
  21. Binary Search Subroutine is defined in bsearch.f90 and the file msort.f90 implements mergesort of an array.