programming-examples/c-sharp/Mathematics/C# Program to Generate the Sum of N Numbers.cs

30 lines
606 B
C#
Raw Permalink Normal View History

2019-11-15 12:59:38 +01:00
/*
* C# Program to Generate the Sum of N Numbers
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace program
{
class Program
{
static void Main(string[] args)
{
int i, sum = 0,n;
Console.Write("Enter the Nth Number : ");
n = int.Parse(Console.ReadLine());
for (i = 0; i <= n; i++)
{
sum = sum + i;
}
Console.WriteLine("\nSum of N Numbers : " + sum);
Console.ReadLine();
}
}
}
/*
Enter the Nth Number : 10
Sum of N Numbers : 55