square.c (#2)

  #include <stdio.h>

  /*  A program to calculate a square area. */
  int main()
  {
     int width, length, area;

     width = 10;
     length = 5;
     area = width * length;
     printf("The dimension is %d by %d\n", width, length);
     printf("The area is %d.\n", area);
     return 0;
  }
  • Here, we want to output width and length. Notice the two %d signs and the commas.
  • What's the output?
    The dimension is 10 by 5
    The area is 50.
    |

 


Where to go

Chapter 2
News Page
Lesson 1 contents
Contacting Me


Roby Joehanes © 2001

Hosted by www.Geocities.ws

1