Asp.net programming we consider all important topic for knowledge about controls,web Services, JSON, Ajax, database, and interview related Question. In this Asp.net and sql server tutorial blog we give many examples of jquery as like How Play YouTube Video in Your Asp.net Website by URL, How to Play YouTube Videos in Asp.net by using Jquery , Jquery Change div background on mouseover in asp.net , JQuery UI Datepicker (Calendar) etc.

Wednesday, February 22, 2017

Number series program (1*1) + (2*2) + (3*3) + (4*4) + (5*5) + ... + (n*n) by parijat

Number series program (1*1) + (2*2) + (3*3) + (4*4) + (5*5) + ... + (n*n) by parijat :


Number series:


using System;

namespace patternProblem.Number
{
    class Number2
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Given series is:");
            Console.WriteLine("(1*1) + (2*2) + (3*3) + (4*4) + (5*5) + ... + (n*n) ");
            Console.WriteLine("----------------------------");
            Console.WriteLine();
            Console.WriteLine("Enter value of n: ");
            int n = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine();
            int sum = 0;

            Console.WriteLine("-----Output-----");
            Console.WriteLine();
            for (int i = 1; i <= n; i++)
            {
                sum = sum + (i * i);
            }
            Console.WriteLine("Sum of series: " + sum);

            Console.ReadKey();
        }
    }
}

No comments:

Post a Comment