VKNikov

Calculating the square root of a random number

Mar 12th, 2014
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.64 KB | None | 0 0
  1. using System;
  2.  
  3. class CalculatingSquareRoot
  4. {
  5.     static void Main()
  6.     {
  7.         //This program calculates the square root of a random number
  8.         Console.WriteLine("Enter a random number for which you want to calculate the square root of:");
  9.         string Userinput = Console.ReadLine();
  10.         double Number;
  11.         if (double.TryParse(Userinput, out Number))
  12.         {
  13.             double SQRT = Math.Sqrt(Number);
  14.             Console.WriteLine("The Square root of {0} is {1}", Number, SQRT);
  15.         }
  16.         else
  17.         {
  18.             Console.WriteLine("Incorrect input data.  Please enter only numbers!");
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment