9


Printing Out and Inputting Variables

C uses formatted output. The printf function has a special formatting character (%) - a character following this defines a certain format for a variable:

%c - characters

%d - integers

%f - floats

e.g. printf("%c%d%f",ch,i,x);

NOTE: Format statement enclosed in "...", variables follow after. Make sure order of format and variable data types match up.

scanf() is the function for inputting values to a data structure: Its format is similar to printf:

i.e. scanf(``%c%d%f'',&ch,&i,&x);

NOTE: & before variables. Please accept this for now and remember to include it. It has to do with pointers which we will meet later


drago@scri.fsu.edu
Jan. 1997