# Program to find the length of a number in C++ (CPP)

By Prof. Fazal Rehman Shamil

C++ Program to Find the Number of Digits from any number
is today’s topic of discussion in this tutorial.

Flowchart of C++ Program to Find the Number of Digits of a number

## Example: When the total digits a number are 1 ## Example: When the total digits a number are 2 C++ Program to Find the Number of Digits Using while loop

## Video Lecture

With Comments – Program to find the length of a number in C++ (CPP)

Output:

## Program of Length of a Number in C++ Using Do While Loop (only for positive values)

Let’s begin with “Program of Length of a Number in C++ Using Do While Loop only for positive values”.
#include<iostream>
using namespace std;
int main()
{
int num;
int i;

cout<<“Please enter a number to find its length”<<endl;
cin>>num;

do
{
num=num/10;
i++;
}
while(num>0);
cout<<“the length of the number is = “<<i<<endl;
system(“pause”);
}

## Program of Length of a Number in C++ Using For Loop (only for positive values)

Let’s begin with “Program of Length of a Number in C++ Using For Loop only for positive values”.

## Program of Length of a Number in C++ Using Functions

Let’s begin with “Program of Length of a Number in C++ Using Functions”.

## Program of Length of a Number in C++ Using Nested if Statement

Let’s begin with “Program of Length of a Number in C++ Using Nested If Statement”.

## Program of Length of a Number in C++ Using for loop and if Statement

Let’s begin with “Program of Length of a Number in C++ Using for loop and If Statement”.

## Program of Length of a Number in C++ Using While Loop

Let’s begin with “Program of Length of a Number in C++ Using while loop”.

Program to find the length of a number in C

With Comments – Program to find the length of a number in C++ (CPP) Prof.Fazal Rehman Shamil (Available for Professional Discussions)
1. Message on Facebook page for discussions,