Create console programs:
Example output:
Enter 5 grades:
90
83
87
98
93
The average is 90.2 and round off to 90.
using System;
using System.Linq;
namespace Average
{
  class Program
  {
    static void Main(string[] args)
    {
      Console.WriteLine("Enter marks");
      string[] arr = Console.ReadLine().Split(' ');
      int[] intArr = new int[arr.Length];
      for (int i = 0; i < arr.Length; i++)
      {
        intArr[i] = int.Parse(arr[i]);
      }
      double avg = Queryable.Average(intArr.AsQueryable());
      Console.WriteLine("Average " + avg+ " round off to " + Convert.ToInt32(avg));
      Console.ReadLine();
    }
  }
}
Comments
Leave a comment