kuruku

FloatOrDouble

Apr 14th, 2014
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.78 KB | None | 0 0
  1. using System;
  2.  
  3. //Which of the following values can be assigned to a variable of type float and which to a variable of type double:
  4. //34.567839023, 12.345, 8923.1234857, 3456.091? Write a program to assign the numbers in variables and print them to
  5. //ensure no precision is lost.
  6.     class FloatOrDouble
  7.     {
  8.         static void Main()
  9.         {
  10.             //34.567839023, 12.345, 8923.1234857, 3456.091
  11.  
  12.             double firstNumber = 34.567839023;
  13.             Console.WriteLine(firstNumber);
  14.             float secondNumber = 12.345f;
  15.             Console.WriteLine(secondNumber);
  16.             double thirdNumber = 8923.1234857;
  17.             Console.WriteLine(thirdNumber);
  18.             float fourthNumber = 3456.091f;
  19.             Console.WriteLine(fourthNumber);
  20.  
  21.         }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment