Basic C# program to find the average of given number by developer

Amatya
Posted by Amatya under C# category on | Points: 40 | Views : 1309
Basic C# program to find the average of given number by developer

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

namespace DNFPractice
{
class Program
{
public static void Main(string[] args)
{
int Num, i, Sum = 0, Avg = 0;
Console.WriteLine("Give the Total Number of Terms in the Array ");
Num = int.Parse(Console.ReadLine());
int[] ArrElements = new int[Num];
Console.WriteLine("Enter the Array Elements ");
for (i = 0; i < Num; i++)
{
ArrElements[i] = int.Parse(Console.ReadLine());
}
for (i = 0; i < Num; i++)
{
Sum += ArrElements[i];
}
Avg = Sum / Num;
Console.WriteLine("Average is {0}", Avg);
Console.ReadLine();
}
}
}


Thanks
Amatya

Comments or Responses

Login to post response