/*
This is the fifth lab of Lab EE107
The purpose of this lab is to understand the iteration with for loop in C
The purpose is to create the code and free of syntax and grammatical errors
Author: Ekwegbalum Unachukwu
Star ID:do2170dt
Date: Feb 13, 2024.
    */
#include <stdio.h>
/*Program to calculate the 100th triangular number for the "for" statement*/

int main(void) {
    int n_EU,triangularNumberEU;
    triangularNumberEU = 0;

    for(n_EU = 1; n_EU <= 100; n_EU = n_EU + 1)
        triangularNumberEU = triangularNumberEU + n_EU;
    
    printf("the 100th triangular number is %i\n", triangularNumberEU);
    return 0;
    /*
    The line `for (n_EU = 1; n_EU <= 100; n_EU = n_EU + 1)` is part of a `for` loop in the C programming language.


The loop is used in this specific program to calculate the 100th triangular number. 
The triangular number is the sum of all positive integers up to a certain number 
(in this case, up to 100). The loop accumulates these numbers into the variable 
`triangularNumberEU`, and once the loop completes, it prints the result.
        
        */
}

Embed on website

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