Challenge 1: Multiplication Table of a Number
Let's try printing the multiplication table of a number in this lesson.
We'll cover the following...
We'll cover the following...
Problem statement
Write a piece of code that will:
- Print the multiplication table of a number
$numup to 10. - You have to use
whileloop for solving this problem. - Your code should return the string
$answith all the values computed from multiplication appended in that string.- Here’s a link showing how you can add values to a string.
Input
An integer.
Output
A string.
Sample Input:
5
Sample output
Here’s an illustration showing what the string $ans should have stored in it at the end of the while loop for the above mentioned input.
Note: Just like it is shown in the picture above, the values in the string should have spaces in between them. You can add a space by simply adding quotation marks with space in between them to your string, like this: " ".
Coding challenge
Write your code below. It is recommended that you try solving the exercise yourself before viewing the solution.
Good Luck!