How to find the sum of array using C# .Net

How to find the sum of array using C# .Net

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace array
{
    class Program
    {
        static void Main(string[] args)
        {
            int temp = 0, n;
            int[] no=new int[10];
            Console.WriteLine("enter size of array");
            n = int.Parse(Console.ReadLine());
            Console.WriteLine("enter 10 array element ");

            
            for (int s = 0; s <= 9; s++)
            {
                no[s] = Convert.ToInt32(Console.ReadLine());
                temp+= no[s];
            }
            Console.WriteLine("sum of {0}",temp);
            Console.ReadLine();
        }
    }
}

Input :  Now you can Enter  No.  1 to 11

Output : 65



 
Previous
Next Post »

2 comments

Write comments