Write a C++ Program to Find the Number of Digits in a number. Here’s simple Program to Find the Number of Digits in a number in C++ Programming Language.
Here is source code of the C++ Program to Find the Number of Digits in a number. The C++ program is successfully compiled and run(on Codeblocks) on a Windows system. The program output is also shown in below.
SOURCE CODE : :
/* C++ Program to Find the Number of Digits in a number */
#include<iostream>
using namespace std;
int main()
{
int n,no,a=0;
cout<<"Enter any positive integer :: ";
cin>>n;
no=n;
while(no>0)
{
no=no/10;
a++;
}
cout<<"\nNumber of Digits in a number [ "<<n<<" ] is :: "<<a<<"\n";
return 0;
}
Output : :
/* C++ Program to Find the Number of Digit in a number */
Enter any positive integer :: 12345
Number of Digits in a number [ 12345 ] is :: 5
Process returned 0
Above is the source code for C++ Program to Find the Number of Digit in a number which is successfully compiled and run on Windows System.The Output of the program is shown above .
Here is source code of the C++ Program to Find the Number of Digits in a number. The C++ program is successfully compiled and run(on Codeblocks) on a Windows system. The program output is also shown in below.
SOURCE CODE : :
Output : :
Above is the source code for C++ Program to Find the Number of Digit in a number which is successfully compiled and run on Windows System.The Output of the program is shown above .
need an explanation for this answer? contact us directly to get an explanation for this answer