Printf Statements

Printf statements offer a flexable way of displaying information to the screen (handyboard LCD in this case).

Syntax

  1. printf("statement");

--or--

  1. printf("statement",variable1, variable2, etc);

Special Characters

These items are included within the "statement" part of printf as formatting instructions.

Syntax Description
\n New Line, Clears the Handyboard Screen.
%d Displays the corresponding variable as a base 10 integer.
%f Displays the corresponding variable as a base 10 floating point number.

The above table shows just a few commonly used examples. Feel free to browse the internet and discover other useful options.

Example

  1. void main()
  2. {
    1. int a;
    2. for(a=0; a < 5; a++)
    3. {
      1. printf("\nThe value of A is %d", a);
      2. a = a + 1;
    4. }
    5. for(a=4; a != 0; a = a - 1)
      1. printf("\nSince A=5, this will be printed");
  3. }