Advertisement
AnitaN

02.PrimitiveDataTypesVariables/02.FloatOrDouble

Mar 9th, 2014
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.65 KB | None | 0 0
  1. //Problem 2.    Float or Double?
  2. //Which of the following values can be assigned to a variable of type float and which to a variable of type double: 34.567839023, 12.345, 8923.1234857, 3456.091? Write a program to assign the numbers in variables and print them to ensure no precision is lost.
  3.  
  4. using System;
  5.  
  6. class FloatOrDouble
  7. {
  8.     static void Main()
  9.     {
  10.         double doubleA=34.567839023;
  11.         float floatB=12.345f;
  12.         double doubleC=8923.1234857;
  13.         float floatD=3456.091f;
  14.         Console.WriteLine("Double type are:{0} and {1}",doubleA,doubleC);
  15.         Console.WriteLine("Float type are:{0} and {1}",floatB,floatD);
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement