C# Program to find sum of elements in a given array

Introduction :

C# Program to find sum of elements in a given array, c# program sum of given array elements.Logic to sum of element in array in C# programming.

C# Program to find sum of elements in a given array

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();
        }
    }
}

OutPut of Program :

C# Program to find sum of elements in a given array

 

Learn Recommended posts :

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *