From de7f47c4db4180f0b1985853a29b22c91fbe3e92 Mon Sep 17 00:00:00 2001 From: pontiuspilates Date: Fri, 1 Nov 2024 13:00:13 +1030 Subject: [PATCH] add example to tan file, with code block and explanation --- .../concepts/math-functions/terms/tan/tan.md | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/content/c-sharp/concepts/math-functions/terms/tan/tan.md b/content/c-sharp/concepts/math-functions/terms/tan/tan.md index 94e32edf7c9..393826c09ec 100644 --- a/content/c-sharp/concepts/math-functions/terms/tan/tan.md +++ b/content/c-sharp/concepts/math-functions/terms/tan/tan.md @@ -28,6 +28,35 @@ The `Math.Tan()` method takes only one parameter, `angle`, an angle in radians o - `NegativeInfinity` - `PositiveInfinity` +## Example + +The following example first converts `30` degrees to radians, then uses the `Math.Tan()` method to return the tangent of that angle. Finally, the `Console.WriteLine()` function prints the result to the console: +```cs +using System; + +public class Example { + public static void Main(string[] args) { + // Define an angle in degrees + double degrees = 30; + + // Convert the angle to radians + double radians = degrees * Math.PI/180; + + // Calculate the tangent of the angle + double tangent = Math.Tan(radians); + + // Display result + Console.WriteLine("The tangent of " + degrees + " degrees is: " + tangent); + } +} +``` + +The example will result in the following output: + +```shell +The tangent of 30 degrees is: 0.577350269189626 +``` + ## Codebyte Example The following example is runnable and returns the tangent of the `angle` given in degrees: