Kotlin 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
fun main(args: Array<String>) {
  print("Enter your number : ")
  val userInput = Scanner(System.`in`)
  var num:Int = userInput.nextInt()
  var sum:Int = 0

  while(num!=0) {
    sum+=num%10
    num/=10;
  }
  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

Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning.