Java Program to Multiply Two Numbers Using Plus (+) Operator

Java program to multiply two numbers using plus (+) operator

// Java program to multiply two numbers 
// using plus "+" operator

import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    int num1 = 0;
    int num2 = 0;
    int mul = 0;

    Scanner myObj = new Scanner(System.in);

    System.out.printf("Enter first number: ");
    num1 = myObj.nextInt();

    System.out.printf("Enter second number: ");
    num2 = myObj.nextInt();

    for (int loop = 1; loop <= num2; loop++)
      mul += num1;

    System.out.printf("Multiplication of %d and %d is: %d\n", num1, num2, mul);
  }
}

Output

Enter first number: 4
Enter second number: 5
Multiplication of 4 and 5 is: 20
Share on:

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Comment