50 likes | 204 Views
MET 50. MAKING YOUR OUTPUT LOOK NICE!. The “IF” statement. Suppose we have the statements: REAL, parameter :: GRAV = 9.81 PRINT*, ‘Value of GRAV is:’,GRAV Might produce: Value of GRAV is: 9.81000000 Can we make this more “attractive”?. The “IF” statement. Yes!
E N D
MET 50 MAKING YOUR OUTPUT LOOK NICE!
The “IF” statement Suppose we have the statements: REAL, parameter :: GRAV = 9.81 PRINT*, ‘Value of GRAVis:’,GRAV Might produce: Value of GRAV is: 9.81000000 Can we make this more “attractive”? MET 50, FALL 2011, CHAPTER 5 PART 1
The “IF” statement Yes! We can use a more sophisticated PRINT statement. “old” PRINT*, GRAV “new” PRINT nn, GRAV nn FORMAT (stuff) MET 50, FALL 2011, CHAPTER 5 PART 1
The “IF” statement “new” PRINT nn, GRAV nn FORMAT (stuff) The FORMAT statement is new. “nn” is called a label number, and must be an integer. The PRINT line tells the compiler to look for the “nn” label for printing instructions. Specifically – format instructions (contained in “stuff”) MET 50, FALL 2011, CHAPTER 5 PART 1
The “IF” statement NOTES… There are several ways to set this up…we will see them thru the semester. Use the PRINT command to print output to the screen. Use the WRITE command to print output to the printer or a data file (later). MET 50, FALL 2011, CHAPTER 5 PART 1