# Pattern 14 #### Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

`1. You are given a number n.2. You've to write code to print it's multiplication table up to 10 in format given below.`
Input Format
`A number x`
Output Format
` `
Question Video
Constraints
`1 <= n <= 10`
Sample Input
`3`
Sample Output
`3 * 1 = 33 * 2 = 63 * 3 = 93 * 4 = 123 * 5 = 153 * 6 = 183 * 7 = 213 * 8 = 243 * 9 = 273 * 10 = 30`

• Editorial

"If at first, you do not succeed; call it version 1.0"

Question:

1. You are given a number x.

2. You have to write code to print it is multiplication table up to 10 in the format given below.

Input format:

A number x

Output format:

x * 1 = x

x * 2 = 2x

x * 3 = 3x

........

x * 10 = 10x

Constraints:

1 <= x <= 10

Solution Approach:

We have to print a multiplication table of the given number 'x'. We run a loop until 10. Saving results of multiplication for print command convenience and write the print command according to the output format.

Code:

```import java.util.*;
public class Main{
public static void main(String[] args)
{
Scanner scn = new Scanner(System.in);
int x = scn.nextInt();
for(int i=1;i<=10;i++)
{
int val = x*i;
System.out.println(x + " * " + i + " = " + val );
}

}
}```

java false  • Related Topics

Run

Run
Id Name