Here I am going to write a C# Program to find the sum of all item of an Integer Array.

C# Program to find the sum of all item of an Integer Array.

Create a Console Application Project and Write the following code.

code lang=”c” collapse=”false”]

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

namespace SumArrayItem
{
class Program
{
static void Main(string[] args)
{

int iNumberOfItem;
Console.WriteLine(“C# Program to Find the sum of all item of an Integer Array”);
Console.WriteLine(“Enter the Number Of “);
iNumberOfItem = Convert.ToInt32(Console.ReadLine());
int[] iNumbers = new int[iNumberOfItem];
Console.WriteLine(“Enter Array Item”);
for (int iCount = 0; iCount < iNumberOfItem; iCount++)
{
iNumbers[iCount] = Convert.ToInt32(Console.ReadLine());
}
int iTotal = 0;
Console.WriteLine(“Calculating Sum”);
for (int iCount = 0; iCount < iNumberOfItem; iCount++)
{
iTotal += iNumbers[iCount];
}
Console.WriteLine(“Sum of all item of an Integer Array {0}”, iTotal);
Console.ReadKey();
}
}
}

[/code]

Output:

sum of all item

View More:

Conclusion:

Hope this post is useful for you if you have just started C# Programming. I would appreciate if you have any Feedback Comments and Suggests,

Thank You.

One Thought to “C# Program to find the sum of all item of an Integer Array”

  1. Great job, This is very great content, I got really good information from this content and it helps me a lot, I hope it can help many people like me.

     

Leave a Comment