Formatted Output Solutions - D Programming Language

Menu

- Learn
- Documentation
  - Language Reference
  - Library Reference
  - Command-line Reference
  - Feature Overview
  - Articles
- Downloads
- Packages
- Community
  - Blog
  - Orgs using D
  - Twitter
  - Calendar
  - Discord (community-run)
  - Forums
  - IRC
  - Wiki
  - Issues
  - Contributing
  - Contributors
  - Foundation
  - Security Team
  - Donate
  - Sponsors
- Resources
  - Tour
  - Books
  - Tutorials
  - Tools
  - Editors
  - IDEs
  - run.dlang.io
  - Visual D
  - Acknowledgments
  - D Style
  - Glossary
  - Sitemap

Search
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

# Formatted Output Solutions

#### Formatted Output Dersi Problem Çözümleri

1. We have already seen that this is trivial with format specifiers:

       import std.stdio;

       void main() {
           writeln("(Enter 0 to exit the program.)");

           while (true) {
               write("Please enter a number: ");
               long number;
               readf(" %s", &number);

               if (number == 0) {
                   break;
               }

               writefln("%1$d <=> %1$#x", number);
           }
       }

2. Remembering that the `%` character must appear twice in the format string to be printed as itself:

       import std.stdio;

       void main() {
           write("Please enter the percentage value: ");
           double percentage;
           readf(" %s", &percentage);

           writefln("%%%.2f", percentage);
       }

Copyright © 1999-2026 by the D Language Foundation | Page generated by Ddoc on Wed Aug 5 11:24:18 2026