Functions Solutions - D Programming Language
Description: D Programming Language
Keywords: 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 GitHub 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.

# Functions Solutions

#### Functions Dersi Problem Çözümleri

1.     import std.stdio;

       void printMenu(string[] items, int firstNumber) {
           foreach (i, item; items) {
               writeln(' ', i + firstNumber, ' ', item);
           }
       }

       void main() {
           string[] items =
               [ "Black", "Red", "Green", "Blue", "White" ];
           printMenu(items, 1);
       }

2. Here are some ideas:
   - Write a function named `drawHorizontalLine()` to draw horizontal lines.
   - Write a function named `drawSquare()` to draw squares. This function could take advantage of `drawVerticalLine()` and `drawHorizontalLine()` when drawing the square.
   - Improve the functions to also take the character that is used when "drawing". This would allow drawing each shape with a different character:

         void putDot(Canvas canvas, int line, int column, dchar dot) {
             canvas[line][column] = dot;
         }

Copyright © 1999-2026 by the D Language Foundation | Page generated by Ddoc on Wed Aug 19 13:28:52 2026