Generates a table of triangular numbers. - C Statement

C examples for Statement:for

Description

Generates a table of triangular numbers.

Demo Code

#include <stdio.h>

int main (void)
{
    int n;//from  ww w. ja  v a 2  s .co m

        printf ("  n        t \n");
        printf ("-----   -------\n");

        for (n = 5; n <= 50 ; n = n + 5)
        {
            printf(" %2i      %4i \n", n, n * (n + 1) / 2);
        }

        return 0;
}

Result


Related Tutorials