Mega Code Archive

 
Categories / C# / Language Basics
 

Int, float, double, decimal

/* Learning C#  by Jesse Liberty Publisher: O'Reilly  ISBN: 0596003765 */  using System;  public class IntFloatDoubleDecValues  {      static void Main()      {          int firstInt, secondInt;          float firstFloat, secondFloat;          double firstDouble, secondDouble;          decimal firstDecimal, secondDecimal;          firstInt = 17;          secondInt = 4;          firstFloat = 17;          secondFloat = 4;          firstDouble = 17;          secondDouble = 4;          firstDecimal = 17;          secondDecimal = 4;          Console.WriteLine("Integer:\t{0}\nfloat:\t\t{1}",              firstInt/secondInt, firstFloat/secondFloat);          Console.WriteLine("double:\t\t{0}\ndecimal:\t{1}",              firstDouble/secondDouble, firstDecimal/secondDecimal);          Console.WriteLine(            "\nRemainder(modulus) from integer division:\t{0}",              firstInt%secondInt);      }  }