You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
606 B
C#

/*
* 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