We are to find the hypotenuse of a triange with the two sides entered by the user.
Variables are defined in the first row. In the next lines, values are assigned to these variables.
In the last line we print the result of processing on the screen.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 | static void Main(string[] args) { double side1, side2, hypo; Console.Write("Side 1 : "); side1 = Convert.ToDouble(Console.ReadLine()); Console.Write("Side 2 : "); side2 = Convert.ToDouble(Console.ReadLine()); hypo = Math.Sqrt(Math.Pow(side1, 2) + Math.Pow(side2, 2)); Console.WriteLine("Hypotenuse : "+hypo); Console.ReadKey(); } |
Output:
You can find more similar examples of programming for this programming language in the site.