Venciity

[ Telerik C#] Primitives And Variables - EX 2

Feb 13th, 2014
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1. // Which of the following values can be assigned to a variable of type float
  2. // and which to a variable of type double: 34.567839023, 12.345, 8923.1234857, 3456.091?
  3.  
  4. using System;
  5.  
  6. namespace _02_FloatAndDouble
  7. {
  8.     class FloatAndDouble
  9.     {
  10.         static void Main()
  11.         {
  12.             // FLOAT can contain real numbers that have up to 7 digits
  13.             // DOUBLE can contain real numbers that have up to 15 - 16 digits
  14.  
  15.             double number1 = 34.567839023d;
  16.             float number2 = 12.345f;
  17.             float number3 = 8923.1234857f;
  18.             float number4 = 3456.091f;
  19.  
  20.             Console.WriteLine("{0}\n{1}\n{2}\n{3}", number1, number2, number3, number4);
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment