Printing Strings

[ Printing Strings ]


Basic output of character strings and physical quantities is handled with the print command.

Example 1 :

    print "Here is one line of output \n";


    Here is one line of output

Character strings are enclosed within quotes (i.e. "....." ).

The escape character "\n" forces output onto a new line.

Example 2 : A single print command can generate multiple lines of output. The statement:

    print "Here is line 1\n" , "Here is line 2\n";


    Here is line 1
    Here is line 2

Example 3 : The tab escape character, \t, can be used to align print output into tidy columns. The single statement

    print "One \tTwo \tThree \n" , "Four \tFive \tSix\n";

will generate something like:

    One    Two    Three
    Four   Five   Six

Developed in April 1996 by Mark Austin
Last Modified June 20, 1996
Copyright © 1996, Mark Austin, Department of Civil Engineering, University of Maryland