| 1. |
write a program in java to check for a special 2-digit number when the sum of the digits is added to the product of the digits the result is the number itself. |
Answer» Program:import java.io.*; import java.util.*; public class Main{ public static void main(String args[]){ int sum = 0; int TEMP = 0; int pro = 1; int j; for(int i = 10 ; i < 100 ; i++){ j = i; while (j>0){ temp = j % 10; sum = sum + temp; j = j/10; } temp = 0; j = i; while(j>0){ temp = j % 10; pro = pro * temp; j = j/10; } if ((sum+pro) == i){ System.out.println(i); temp = 0; sum = 0; pro = 1; } temp = 0; sum = 0; pro = 1; } } } Output:19 29 39 49 59 69 79 89 99 Explanation:
-----Hope This Program Helps You :) |
|