ICS 101 - Computer programming

                                          Lab # 1

                                  (Windows & FORTRAN)

 

Objectives

 

 

Following are some exercises to familiarize you with the Use of Microsoft FORTRAN Visual Workbench

 

Exercise 1: Creating, Saving, Compiling, Building and Executing  a Program

 

In this exercise, you will learn how to create a new program, save , compile, build and execute it.

 

1.   Launch FORTRAN DEVELOPER STUDIO

 

2.   From the  File  menu, choose the  New  option then in dialogue box choose  Project Workspace ( i.e. File   New

      Project Workspace)

      You will see a new Window. On left side you will find different type of Applications, Select  Console Application

      In the Name field type Project Workspace Name (e.g. LAB1A). Press the  Create  Button

 

3.   From the  File  menu, choose the  New  option again then in dialogue box choose  Text File.  Click  OK  button. You will find an editing window.

 

4.    From the  File menu, choose the  Save As  option. Save your program with some name (e.g. P1.FOR)

 

5.    In the active window, type in the following program starting after the green line. (Column 7)

       note: 10 is before the green line

 

 

                

 

 

6.   From the  Build  menu, choose the  Compile P1.FOR  option, If a dialogue box appears “This file is not included in the project.

     Would you like to add it? Click  Yes  button.

 

7.   From the  Build  menu, choose the  Build.exe  option.

 

8.   From the  Build  menu, choose the  Execute.exe  option.

 

       Following is the output of the program.

 

              

 

 

Error Handling

 

1.   In the previous program, change the PRINT statement in the third line to PRI

 

2.   Save the program

 

3.   Compile it

 

4.   Now your program will show the following error message

 

              

 

    This means there is an error in Line 3 of your program.

    Press F4 to see the first error, the FORTRAN System now shows your program with the line

    having the error shown in Blue color. Press F4 to go to next error and so on.

 

    Correct the error(s). Compile, Build and Execute your program again.

 

 

Exercise 2:

 

1.    Create New Project workspace  (e.g. LAB1B)

 

2.    Add FORTRAN file in the project

 

3.    Save it with a name (e.g. P2.FOR)

 

4.    In the active window, type in the following program starting after the green line.

     

 

             

 

 

5.    From the  Build  menu, choose the  Compile P2.FOR  option, If a dialogue box appears “This file is not included in the project . Would you like to add it? Click  Yes  button.

 

6.    From the  Build  menu, choose the  Build.exe  option.

 

7.    From the  Build  menu, choose the  Execute.exe  option.

 

      Following is the output of the program