C++ Program:

- To print total number of digits in a number

Example:

User Input: 45

Output:
Sum of total number of digits : 9

#include <iostream>
using namespace std;

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

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.