Generate a table of squared numbers. - C Statement

C examples for Statement:for

Description

Generate a table of squared numbers.

Demo Code

#include <stdio.h>

int main (void)
{
    int n;/*from   w ww.  j  av  a 2 s .  c o  m*/

    printf ("  n      n^2 \n");
    printf ("-----   -----\n");

    for ( n = 1; n < 11; n++ )
    {
        printf (" %2i     %3i \n", n, n * n);
    }

    return 0;
}

Result


Related Tutorials