C# Program to Find a Number using Pythagoras Theorem

In geometry, Pythagoras theorem is used to find the length of the hypotenuse of a right-angled triangle. In this task, we will write a C# program to find a number using Pythagoras theorem.

Problem Statement

Write a C# program to find a number using Pythagoras theorem. The program should take input from the user in the form of the length of the two sides of a right-angled triangle. The program should display the length of the hypotenuse as output.

C# Program to Find a Number using Pythagoras Theorem

using System;

class Program
{
    static void Main(string[] args)
    {
        double a, b, c;
        Console.WriteLine("Enter the First Value ");
        a = double.Parse(Console.ReadLine());
        Console.WriteLine("Enter the Second Value ");
        b = double.Parse(Console.ReadLine());
        c = Math.Sqrt(a * a + b * b);
        Console.WriteLine("The Other Number is : {0}", c);
        Console.ReadLine();
    }
}

Input / Output

C# Program to Find a Number using Pythagoras Theorem

Share:

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

This C# program calculates and displays an upper triangular matrix based on user input. Problem Statement: The program takes the...
This C# program serves as a demonstration of bitwise operators, which are fundamental operators used for manipulating individual bits in...
This C# program is designed to interchange or swap the columns of a matrix. A matrix is a two-dimensional array...