Java Program:

- To print total number of digits in a number

Example:

User Input: 45

Output:
Sum of total number of digits : 9

import java.util.Scanner;
public class SumDigits {
  public static void main(String []args) {
    int num,sum=0;
    Scanner userInput = new Scanner(System.in);
    System.out.print("Enter Your number : ");
    num = userInput.nextInt();

    while(num!=0) {
      sum+=num%10;
      num/=10;
    }
    System.out.println("Sum of total number of digits : "+sum);
  }
}

Output:

  Enter Your number : 1132
  Sum of total number of digits : 7
Program
number

Main Logic :

while(num!=0) {
  sum+=num%10;    //Find single digits, & add them
  num/=10;
}
Concept

Coming Soon !

Quick
Tutorial

Quote

The best preparation for good work tomorrow is to do good work today.