Search This Blog

This website completely moved to new domain. For latest content, visit www.programmingposts.com

C# Program To Print Sum Of Series 1+2+3+..+n



c# program to print sum of series 1+2+3+....+n

using System;

namespace SumOfSeries
{
    class Program
    {
        static void Main(string[] args)
        {
            int sum = 0, i, n;
            Console.WriteLine("\n>>> C# Program to print Sum of Series 1+2+3+..+n <<<\n");
            Console.Write("\n Enter the number of terms:");
            n=Convert.ToInt32(Console.ReadLine());
            for (i = 1; i <= n; i++)
            {
                sum += i;
            }
            Console.WriteLine("\n Sum of series upto  {0} is : {1}", n, sum);
            Console.ReadLine();

        }
    }
}
..
Output:


5 comments:

  1. A great post that explains the important ideas clearly. The content is both engaging and educational.azure devops training online

    ReplyDelete
  2. Thanks for sharing this informative post! A comprehensive MongoDB training course helps learners understand CRUD operations, aggregation pipelines, indexing, schema design, and database performance optimization. Hands-on practice can make it easier to apply MongoDB concepts in real-world applications.mongodb training

    ReplyDelete
  3. This article provides good information for readers who want to improve their technical knowledge. Keep sharing helpful content.learn ui path

    ReplyDelete