Implement the Pythagorean Theorem in CSharp

Description

The following code shows how to implement the Pythagorean Theorem.

Example


using System;  /*from   www  .  ja  v  a  2 s. c o  m*/
  
public class Pythagorean {     
  public static void Main() {     
    double s1; 
    double s2; 
    double hypot; 
 
    s1 = 12.12; 
    s2 = 13.13; 
 
    hypot = Math.Sqrt(s1*s1 + s2*s2); 
  
    Console.WriteLine("Hypotenuse is " + hypot); 
  }     
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Data Types »




C# Data Types
Bool
Byte
Char
Decimal
Double
Float
Integer
Long
Short
String
C# Array
Array Example
Byte Array
C# Standard Data Type Format
BigInteger
Complex
Currency
DateTime
DateTimeOffset
DateTime Format Parse Convert
TimeSpan
TimeZone
Enum
Null
tuple
var