-
Language
C#
-
Description
It determines the square root if the entered value is a positive number. If the value is a negative value it says that it is an imaginary solution.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System;
namespace SquareRoot
{
class SquareRoot
{
static void Main(string[] args)
{
double a_number, square_root;
Console.Write("Enter the value of a number: ");
a_number = double.Parse(Console.ReadLine());
if(a_number>=0)
{
square_root=Math.Sqrt(a_number);
Console.WriteLine("Real root");
}
else
{
square_root=Math.Sqrt(-a_number);
Console.WriteLine("Imaginary root");
}
Console.WriteLine("Value of square root: " + square_root);
Console.WriteLine();
Console.Write("Press any key to finish . . . ");
Console.ReadKey();
}
}
}
namespace SquareRoot
{
class SquareRoot
{
static void Main(string[] args)
{
double a_number, square_root;
Console.Write("Enter the value of a number: ");
a_number = double.Parse(Console.ReadLine());
if(a_number>=0)
{
square_root=Math.Sqrt(a_number);
Console.WriteLine("Real root");
}
else
{
square_root=Math.Sqrt(-a_number);
Console.WriteLine("Imaginary root");
}
Console.WriteLine("Value of square root: " + square_root);
Console.WriteLine();
Console.Write("Press any key to finish . . . ");
Console.ReadKey();
}
}
}