Next: Arithmetic Operations Up: Variables Previous: Defining Global Variables

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:

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 is to do with pointers which we will meet later (Section ).


Dave.Marshall@cm.cf.ac.uk
Wed Sep 14 10:06:31 BST 1994