for-Loops
Mit for-Loops können wir Codeblöcke wiederholen, bis eine bestimmte Bedingung erfüllt ist.
for (initialization; condition; iteratore)
{
..
}int n = 5,
int sum = 0;
for (int i = 1; i <= n; i++)
{
sum += i;
}
Console.WriteLine($"Sum of first {n} natural numbers = {sum}");Last updated