Q:

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

belongs to collection: C++ Basic Solved Programs

0

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.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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 .

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C++ Basic Solved Programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
C++ Program to Generate Fibonacci Series for N num... >>
<< C++ Program to Reverse a Number using while loop...