Decode School

Decode School - The School for Problem Solvers

Welcome to my blog. Subscribe and get my latest blog post in your inbox.

Java Program to multiply two numbers without using * operator

Get two inputs num1 and num2, compute the product of num1 and num2 without using * operator

Sample Input 1:

5 6

Sample Output 1:


Program or Solution


Program Explanation

Instruction(s) inside the for block{} are executed repeatedly till the second expression (i<=table)is true.

Here i is initialized to 1 and incremented by 1 for each iteration, instructions inside the for block are executed unless i becomes greater than m.

so value of i (1,2,3,...m)will be add num2 with m time and printed in table format.