...

/

Solution: Print a parallelogram pattern

Solution: Print a parallelogram pattern

Here is a solution to the coding challenge given in the previous lesson.

We'll cover the following...

Solution #

Here is a code that will print a parallelogram pattern of # characters using two for loops:

Press + to interact
import std.stdio;
void printParallelogram() {
int rows = 5;
int cols = 8;
for (int line = 0; line < rows; ++line) {
for (int i = 0; i < line; ++i) {
write(' ');
}
writeln("########");
}
}

Solution explanation

...