Three
digital number is given. Find the product of its digits.
Input. One three digital positive integer n.
Output. Print the product of digits in n.
Sample input |
Sample output |
235 |
30 |
elementary problem
Let n be the three-digital number. Then:
·
number
of its hundreds a equals
to n /
100;
·
number
of its tens b equals
to n /
10 % 10;
·
number
of its ones c equals
to n %
10;
Now we must find and print the
product a * b * c.
Algorithm realization
Read input
data.
scanf("%d",&n);
Find the digit of hundreds a, of tens b and of ones c.
a
= n / 100;
b
= n / 10 % 10;
c
= n % 10;
Find and print the product of digits.
res
= a * b * c;
printf("%d\n",res);
Java realization
import java.util.*;
public class Main
{
public static void
main(String []args)
{
Scanner con = new Scanner(System.in);
int n = con.nextInt();
int a = n / 100;
int b = n / 10 % 10;
int c = n % 10;
int res = a * b * c;
System.out.println(res);
con.close();
}
}
Python realization
n = int(input())
a = n // 100
b = n // 10 % 10
c = n % 10
res = a * b * c
print(res)