This C# Program **Generates the Sum of N Numbers**. This Python program obtains the Nth number from the user and calculates its sum till the Nth number.

Here is source code of the C# Program to Generate the Sum of N Numbers.

**Code:**

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
class Program { static void Main(string[] args) { int number, sum=0; Console.Write("Enter a Number : "); number = Convert.ToInt32(Console.ReadLine()); if(number<0) { Console.Write("Please Enter Positive Number"); } else { while(number>0) { sum += number; number -=1; } } Console.WriteLine("The sum is "+sum); Console.ReadKey(); } } |

**Output:**

[…] Generates the Sum of N Numbers in C# […]