Untitled
unknown
plain_text
a year ago
1.2 kB
8
Indexable
using System;
class Program
{
static void Main()
{
Console.WriteLine("Четните числа от 1 до 100:");
PrintEvenNumbers();
Console.WriteLine("\nКвадратните корени на четните числа (закръглени до 2 знака):");
PrintSquareRoots();
Console.WriteLine("\nЧетните числа с точни квадратни корени:");
PrintPerfectSquareEvens();
}
static void PrintEvenNumbers()
{
for (int i = 2; i <= 100; i += 2)
{
Console.Write(i + " ");
}
Console.WriteLine();
}
static void PrintSquareRoots()
{
for (int i = 2; i <= 100; i += 2)
{
double sqrtValue = Math.Sqrt(i);
Console.WriteLine($"√{i} ≈ {Math.Round(sqrtValue, 2)}");
}
}
static void PrintPerfectSquareEvens()
{
for (int i = 2; i <= 100; i += 2)
{
double sqrtValue = Math.Sqrt(i);
if (Math.Floor(sqrtValue) == sqrtValue) // Проверка дали е цяло число
{
Console.WriteLine($"{i} (√{i} = {sqrtValue})");
}
}
}
}Editor is loading...
Leave a Comment