Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class sumdigit {
- public static void main(String args[])
- {
- Scanner src=new Scanner(System.in);
- System.out.println("Enter the number");
- int a=src.nextInt();
- int n,sum=0;
- while (a>0)
- {
- n=a%10;
- sum=sum+n;
- a=a/10;
- }
- System.out.println("The sum is "+sum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement