Advertisement
Guest User

D for Loop

a guest
Jul 30th, 2015
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 0.41 KB | None | 0 0
  1. /*
  2.     Compute heights in centimeters for a range of heights
  3.     expressed in feet and inches
  4. */
  5. import std.stdio;
  6.  
  7. void main() {
  8.     // Values unlikely to change soon
  9.     immutable inchesPerFoot = 12;
  10.     immutable cmPerInch = 2.54;
  11.  
  12.     // Loop'n write
  13.     foreach (feet; 5 .. 7) {
  14.         foreach (inches; 0 .. inchesPerFoot) {
  15.             writeln(feet, "'", inches, "\"\t",
  16.                 (feet * inchesPerFoot + inches) * cmPerInch);
  17.         }
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement