Write a C# Sharp program that displays the sum of n natural numbers.

 


using System;

public class Program
{
    public static void Main(string[] args)
    {
        int sum = 0;
        int n = 10; // Replace 10 with the number of natural numbers you want to sum

        for (int i = 1; i <= n; i++)
        {
            sum += i;
        }

        Console.WriteLine("The sum of the first {0} natural numbers is {1}", n, sum);
    }
}
Write a C# Sharp program that displays the sum of n natural numbers. Write a C# Sharp program that displays the sum of n natural numbers. Reviewed by Bhaumik Patel on 8:53 PM Rating: 5