Number of Digits in a number
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 .
If you found any error or any queries related to the above program or any questions or reviews , you wanna to ask from us ,you may Contact Us through our contact Page or you can also comment below in the comment section.We will try our best to reach up to you in short interval.
Thanks for reading the post….
sir this program is only count till the 10 digit not more than 10 digit……
if you give the input 14 digit number then output is only 10 . [12345678912345}
just declare int -> long;
The long unity have more byte capacity