top of page
Click here to go to the home page of AskTheCode.

Product of digits of a two digit number in Java | AskTheCode

Team ATC

How to find product of digits of a two digit number in Java | AskTheCode

 

import java.util.Scanner;


class productOfDigitsOfNumber{

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

System.out.println("Enter a two digit number: ");

int n = sc.nextInt();

int product = 1;

product = n % 10;

n = n - product;

n = n / 10;

product *= n;

System.out.println("The product is: "+product);

}

}


Recent Posts

See All

Komentar


bottom of page