Challenge 3: Printing Pyramid
Test your understanding of loops by printing a half pyramid for a given number of rows in this lesson.
We'll cover the following...
We'll cover the following...
Problem statement
Write code which prints half a pyramid of the alphabet a.
- The code takes an integer variable
$rowsas input and prints the pyramid with that number of rows displayinga.
Hint: Use
forloops to implement the solution.
Input
An integer.
Output
Print the character a on the console.
Sample input
$rows is equal to 5.
Sample output
Note: In order to move values to next line you can use
\n.
Coding challenge
Write your code below. It is recommended that you try solving the exercise yourself before viewing the solution.
Good Luck!