Note: This website is archived. For up-to-date information about D projects and development, please visit

Get a number from the user (uses scanf)

Part of TutorialFundamentals


Shows how you can ask the user for a number during runtime.


import std.stdio; /* for write/writefln */

int main() 
    double n;

    write("Pick a number: ");
    scanf("%lf", &n);

    writefln("You picked: %s", n);
    return 0;