;

C# Program to Generate the Sum of N Numbers


Tutorialsrack 11/08/2019 C# Programs

In this C# program, we will learn how to write a program to generate the sum of N numbers.

Here is the code of the program to generate the sum of N numbers:

Code - C# Program To generate the sum of N numbers.
using System;

namespace TutorialsrackPrograms
{
    class Program
    {
        //C# Program to Generate the Sum of N Numbers.
        static void Main(string[] args)
        {
            int i, sum = 0, number;
            Console.Write("Enter the Nth Number: ");
            number = int.Parse(Console.ReadLine());
            for (i = 0; i <= number; i++)
            {
                sum = sum + i;
            }
            Console.WriteLine("\nSum of N Numbers : " + sum);
            Console.Read();
        }
    }
}
Output

Enter the Nth Number: 50

Sum of N Numbers: 1275


Related Posts



Comments

Recent Posts
Tags