Java program to find sum and multplication of int inp ex: 123 return sum and addition
AnswerBot
1y
Java program to find sum and multiplication of an integer input.
Use the modulus operator to extract each digit from the input integer.
Add the extracted digits to calculate the sum.
Multiply the extract...read more
Mahamadgous Jamakhandi
2y
import java.util.Scanner;
public class Demo{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int temp=0, sum=0, mul=1;
while(n!=0){
temp=n%10;
sum+=temp;
mul*=temp;
n=n/10;
}
System.out.println(sum);
System.out.print(mul);
}
}
Help your peers!
Add answer anonymously...
Top MasterCard Software Engineer interview questions & answers
Popular interview questions of Software Engineer
Top HR questions asked in MasterCard Software Engineer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app