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...
MasterCard Software Engineer interview questions & answers
A Software Engineer was asked 5mo agoQ. Explain the concepts introduced in Java 8.
A Software Engineer was asked 5mo agoQ. What is the internal working of a HashMap in Java?
A Software Engineer was asked Q. Write a Java stream to filter a JSON object containing State based on given filt...read more
Popular interview questions of Software Engineer
A Software Engineer was asked 5mo agoQ1. Explain the concepts introduced in Java 8.
A Software Engineer was asked Q2. Write a Java stream to filter a JSON object containing State based on given filt...read more
A Software Engineer was asked Q3. How do you use a proxy for routing?
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

