Count digit from an Integer Number

Take input from user and count the number of digit from an integer number. For example if you take 2017, the output will be 4.
Put your answer in comment section. You may use dropbox link here.

21 comments:

  1. //Count Digit from an Integer Number
    #include
    using namespace std;

    int main()
    {
    int no,a=0;
    cout<<"Enter any num : ";
    cin>>no;
    while(no>0)
    {
    no=no/10;
    a++;
    }
    cout<<"\n No. of digits in given number is : "<<a;
    }

    ReplyDelete
  2. //count digit form an integer number
    #include
    using namespace std;

    int main()
    {
    int Number,a=0;
    cout<<"Enter any num : ";
    cin>>Number;
    if(Number<0)
    {
    Number=Number * -1;
    }
    else if(Number==0)
    {
    Number=1;
    }
    while(Number>0)
    {
    Number=Number/10;
    a++;
    }
    cout<<"\n Number of Digit = "<<a;
    }

    ReplyDelete

  3. #include
    using namespace std;

    int main()
    {
    int num,i=0;
    cout<<"Give me the number, i shall count : ";
    cin>>num;
    while(num>0)
    {
    num=num/10;
    i++;
    }
    cout<<"\n Well , Dear, This integer number contains this much digits: : "<<i;
    }

    ReplyDelete
  4. #include
    using namespace std;
    int main()
    {
    int n, i;
    cout << "Enter a number: ";
    cin >> n;
    if(n>=10){
    for( i=0; n>0; i++){
    n=n/10;
    }
    cout << "Digits are " << i << endl;
    }else{
    cout << "Sorry i am not calculate over than 10 Digit Please try agin";
    }
    return 0;
    }

    ReplyDelete
  5. //C++ Program to Count Number of Digits in a Number defined by user

    #include
    using namespace std;
    int main()
    {
    int number, count;

    cout<<"Please Enter any number"<>number;

    for (count=0; number > 0;number=number/10)
    {
    count=count + 1;
    }

    cout<<"Total Number of Digit = "<<count;
    }

    ReplyDelete
  6. #include
    using namespace std;
    int main()
    {
    int n, count=0;
    cout << "Enter a number: ";
    cin >> n;
    do{
    n=n/10;
    count++;
    }
    while(n>0);
    cout << "Digits are " << count << endl;
    return 0;
    }

    ReplyDelete
  7. Md.Nazrul Islam, ID: 201630769January 20, 2017 at 9:15 PM

    #include
    using namespace std;
    int main()
    {
    int number,digit_count,original_number;
    digit_count=0;
    cout<<
    "Enter your number here:";
    cin>>number;
    original_number=number;
    while(number>0)
    {
    digit_count=digit_count+1;
    number/=10;
    }
    cout<<
    "Total digit of this number "<<original_number <<" is: "<<digit_count;
    return 0;
    }

    ReplyDelete
  8. #include
    using namespace std;
    int main ()
    {
    int a, count=0;
    cout << "Enter a number:";
    cin>> a;
    do {
    a=a/10;
    cout++;
    while (a>0);
    cout <<" Digit are "<<cout <<endle
    return 0;
    }

    ReplyDelete
    Replies
    1. #include
      using namespace std;
      int main()
      {
      int n, count=0;
      cout << "Enter a number: ";
      cin >> n;
      do{
      n=n/10;
      count++;
      }
      while(n>0);
      cout << "Digits are " << count << endl;
      return 0;
      }

      Delete
    2. #include
      using namespace std;
      int main()
      {
      int n, count=0;
      cout << "Enter a number: ";
      cin >> n;
      do{
      n=n/10;
      count++;
      }
      while(n>0);
      cout << "Digits are " << count << endl;
      return 0;
      }

      Delete

  9. #include
    using namespace std;

    int main()
    {
    int num,a=0;
    cout<<"Enter any number";
    cin>>num;
    while(num>0)
    {
    num=num/10;
    a++;
    }
    cout<<"\n The given number is : "<<a;
    }

    ReplyDelete
  10. #include
    using namespace std;
    int main()
    {
    int value,a=0;
    //clrscr();
    cout<<"Enter a number what your chose = ";
    cin>>value ;
    cout<<"Thanks you for chose a value ";
    while(value>0)
    {
    value=value/10;
    a++;
    }
    cout<<"\nThe result is = "<<a;

    //getch();
    }

    ReplyDelete
  11. #include
    using namespace std;
    Int main () {

    Int Number,i= 0;
    cout<<"Enter your number : ";
    cin>>Number;
    while (Number !=0){
    Number = Number/10;
    i++;
    }
    cout<<"The Number : "<<i;
    }

    ReplyDelete
  12. //Count Digit from an Integer Number
    #include
    using namespace std;
    int main()
    {
    int i=0;
    double x;
    cout << "Enter a number: ";
    cin >> x;
    while(x > 1)
    {
    i++;
    x = x/10;
    }
    cout<<"\n Total digits: "<<i;
    }

    ReplyDelete
  13. #include
    using namespace std;

    int main()
    {
    int num,i=0;
    cout<<"Give me the number, i shall count : ";
    cin>>num;
    while(num>0)
    {
    num=num/10;
    i++;
    }
    cout<<"\n Well , Dear, This integer number contains this much digits: : "<<i;
    }

    ReplyDelete
  14. #include
    using namespace std;

    int main()
    {
    int num,a=0;
    cout<<"Enter any num : ";
    cin>>num;
    for(a=0;num>0;)
    {
    num=num/10;
    a++;
    }
    cout<<"\n No. of digits in given number is : "<<a;
    }

    ReplyDelete

Comment Here