- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to find a number using Pythagoras Theorem using C#?
Firstly, set the first two numbers −
double val1, val2; val1 = 10; val2 = 5;
Now use the Math.Sqrt function to use Pythagoras Theorem.
res = Math.Sqrt(val1 * val1 + val2 * val2);
Example
using System; public class Program { public static void Main(string[] args) { double val1, val2, res; val1 = 10; val2 = 5; res = Math.Sqrt(val1 * val1 + val2 * val2); Console.WriteLine("Result = {0}", res); Console.ReadLine(); } }
Output
Result = 11.1803398874989
Advertisements