Calculating the 200th Triangular Number with the for statement. - C Data Type

C examples for Data Type:int

Description

Calculating the 200th Triangular Number with the for statement.

Demo Code

#include <stdio.h>

int main (void)
{
    int n, triangularNumber;

    triangularNumber = 0;/*from   ww  w. j a v a 2 s . c  o m*/

    for (n = 1; n <= 200; n = n + 1)
        triangularNumber = triangularNumber + n;

    printf ("The 200th triangular number is %i\n", triangularNumber);

    return 0;
}

Result


Related Tutorials