Kotlin Program:

- To print total number of digits in a number

Example:

User Input: 15

Output:
Total number of digits : 2

import java.util.Scanner
fun main(args: Array<String>) {
  print("Enter your number : ")
  val userInput = Scanner(System.`in`)
  var num:Int = userInput.nextInt()
  var count:Int = 0

  while(num!=0) {
    num/=10;
    count++;
  }
  println("Total number of digits : $count")
}

Output:

  Enter Your number : 1132
  Total number of digits : 4
Program
number

Main Logic :

while(num!=0){
  num/=10;  // num=num/10
  count++;
}

Divide the number by 10 while your number becomes 0[ZERO]
& Just count how many times it divides the number to make it ZERO

Concept

Coming Soon !

Quick
Tutorial

Quote

A good decision is based on knowledge and not on numbers.