Добавить возврат значения из программы - C#
Формулировка задачи:
static void Main(string[] args)
{
double a, b, c;
Console.WriteLine("Введите 1 число");
a = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Введите 2 число");
b = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Введите 3 число");
c = Convert.ToDouble(Console.ReadLine());
if (a > 0)
{
Console.WriteLine("Число " + a + " в квадрате: " + a * a);
}
if (b > 0)
{
Console.WriteLine("Число " + b + " в квадрате: " + b * b);
}
if (c > 0)
{
Console.WriteLine("Число " + c + " в квадрате: " + c * c);
}
Console.ReadKey();Решение задачи: «Добавить возврат значения из программы»
textual
Листинг программы
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DZ11
{
class Program
{
static void CalculateArea(double r)
{
if (r > 0)
{
Console.WriteLine("Число {0} в квадрате: {1}", r, r*r);
}
return;
}
static void Main(string[] args)
{
double a, b, c;
Console.WriteLine("Введите 1 число");
a = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Введите 2 число");
b = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Введите 3 число");
c = Convert.ToDouble(Console.ReadLine());
CalculateArea(a);
CalculateArea(b);
CalculateArea(c);
Console.ReadKey();
}
}
}