C# Program to print sum of first 10 natural numbers
In this program, You will learn how to print the sum of the first 10 natural numbers in C#.
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = 55
Example: How to print the sum of the first 10 natural numbers in C#.
using System;
public class Program
{
public static void Main(string[] args)
{
int i, s = 0;
for (i = 1; i <= 10; i++)
{
s = s + i;
}
Console.WriteLine("Sum is:" + s);
}
}
Output:
Sum is:55