#include <stdio.h>

int main(void) {
    // Declaration of variables
    double n_EU, number_EU, triangularNumberEU, counter_EU;
    triangularNumberEU = 0;

    // Outer loop to handle five sets of input
    for (counter_EU = 1; counter_EU <= 7; ++counter_EU) {
        // Prompt user for input
        printf("What triangular number do you want to enter?\n");

        // Read user input
        scanf("%lf", &number_EU);

        // Reset triangularNumberEU for each set of input
        triangularNumberEU = 0;

        // Inner loop to calculate the triangular number
        for (n_EU = 1; n_EU <= number_EU; ++n_EU) {
            triangularNumberEU += n_EU;
        }

        // Display the result for each set of input
        printf("The triangular number %.0lf is %.0lf\n\n", number_EU, triangularNumberEU);
    }

    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: