0
How can we print average of 5 number using if else
4 Respostas
+ 7
You can use LINQ.
using System.Linq
...
static void Main()
{
int[] mas = {4, 6, 5, 2, 3};
double result = mas.Average(); // computes the average of sequence
}
+ 4
there is no need of if else for finding average of 5 numbers
+ 4
int[] nums = new int[5];
int sum = 0;
for (int i = 0; i < nums.Length; i++)
{
Console.Write("Enter num"+(i+1) +": ");
nums[i] = int.Parse(Console.ReadLine());
sum+= nums[i];
}
int ave = sum/5;
Console.WriteLine("Ave: " + ave);
NO NEED FOR IF ELSE.
Hope that helps!
+ 2
@Andrii Tymochko the fourth question was wrong