Use minimum field width modifier to produce tables. - C Language Basics

C examples for Language Basics:printf

Introduction

The following program produces a table of squares and cubes for the numbers between 1 and 19:

Demo Code

#include <stdio.h>

int main(void)
{
   int i;/*from www.j av  a 2  s . com*/

   /* display a table of squares and cubes */

   for (i = 1; i<20; i++)
      printf("%8d %8d %8d\n", i, i*i, i*i*i);

   return 0;
}

Result


Related Tutorials