C++ Program:

- To print total number of digits in a number

Example:

User Input: 15

Output:
Total number of digits : 2

#include <iostream>
using namespace std;

int main() {
  int num,count=0;
  cout<<"Enter Your number : ";
  cin>>num;
  while(num!=0){
    num/=10;
    count++;
  }
  cout<<"Total number of digits :"<<count;
  return 0;
}

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.