Write a Program to display count of the sum of the digits.
import java.util.Scanner;
public class CountSumOfDigits {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter the number : ");
int no = sc.nextInt();
int count = 0;
while(no>0){
count++;
no/=10;
}
System.out.print("Count of the number : "+count);
sc.close();
}
}
Output of program :
Comments
Post a Comment