Нужно сделать прогу в Visual Studio C#
- написати програму, яка буде обчислювати середнє арифметичне 5 чисел, що вводяться з клавіатури.

26 Сен 2019 в 04:44
236 +1
0
Ответы
1

Sure, here is a code example in C# that calculates the average of 5 numbers entered by the user from the keyboard:

using System;
namespace AverageCalculator
{
class Program
{
static void Main(string[] args)
{
int sum = 0;
int number;
Console.WriteLine("Enter 5 numbers to calculate their average:");
for (int i = 0; i < 5; i++)
{
Console.Write("Enter number {0}: ", i+1);
number = Convert.ToInt32(Console.ReadLine());
sum += number;
}
double average = (double)sum / 5;
Console.WriteLine("The average of the 5 numbers is: {0}", average);
}
}
}

You can copy and paste this code into a new C# console application project in Visual Studio and run the program to calculate the average of 5 numbers entered by the user.

19 Апр 2024 в 19:26
Не можешь разобраться в этой теме?
Обратись за помощью к экспертам
Гарантированные бесплатные доработки в течение 1 года
Быстрое выполнение от 2 часов
Проверка работы на плагиат
Поможем написать учебную работу
Прямой эфир