{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

08InputOutput-handout

08InputOutput-handout - Input and Output Formats Winter...

Info icon This preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
Input and Output Formats Winter 2009 Amir Hossein Rabbani
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
What happened to * ? WRITE ( * , * ) READ ( * , * ) Target: screen / keyboard, file Format
Image of page 2
Fortran Formats The READ and WRITE statements we have seen so far are called free-format statements. The are easy to use but we have no control over the placement of the input or appearance of the output. To control the appearance of of the input and output, Fortran allows us to use format specifications .
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Name: Barack Obama Data of Birth: August 4, 1961 Nationality: American Electoral won: 365 Name: Barack Obama Data of Birth: August 4, 1961 Nationality: American Electoral won: 365 Which one is nicer? QuickTimeª and a decompressor are needed to see this picture. QuickTimeª and a decompressor are needed to see this picture.
Image of page 4
Formats Allow us to specify the placement of values both in output and input Using format descriptors we can control: The appearance of output values Repetition Vertical positioning Horizontal positioning
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Methods of Using Format ( format specifications ) WRITE ( * , ) WRITE ( * , label ) label FORMAT WRITE ( * , ( F.15 ) ) cost WRITE ( * , 100 ) cost 100 FORMAT ( F.15 ) e.g.
Image of page 6
Format Codes Most common format letters: F real numbers, fixed point format I integer A text string E real numbers, exponent notation X horizontal space / vertical space e.g. 100 FORMAT ( F 10.4)
Image of page 7

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Real Values Fixed point notation F w . d Fixed point notation Width Decimal REAL :: X = 1100.1003 WRITE(*,”( F 10 . 4 )”) X # 1100. 1003 output d = 4 w = 10 including space and ‘.’ # means space
Image of page 8
Note Output is right adjusted, i.e. spaces are added to the left Width includes space for : 1. d decimal digits 2. The decimal point 3. The whole number 4. The sign, if the number is negative
Image of page 9

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Example PROGRAM
Image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern