How Printing and Inputting Variables in C , Printf() and Scanf() Using

Printing and Inputting Variables, Printf() and Scanf() Using

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 is 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.

Labels: