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.

41 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
  15. This comment has been removed by the author.

    ReplyDelete
  16. /*******************************
    Forhad Parvez
    CSE - 55th Batch
    C++ - 2018
    ********************************/

    #include

    using namespace std;

    class input{
    public:
    int num;
    void getdata(){
    cin>>num;
    }
    };

    class calc : public input {
    public:
    int newval(){
    int count=0;
    while(num>0){
    num=num/10;
    count++;
    }

    return count;
    }

    };



    int main()
    {
    calc obj;
    cout<<"Please Enter A Number : ";
    obj.getdata();
    cout<<"Total Number : "<<obj.newval();
    return 0;
    }



    ReplyDelete
    Replies
    1. Forhad Parvez
      Roll : 201720297

      Delete
  17. sayeka jannat
    ID:201720097
    Batch:55th
    I could not use Dropbox Gave directly


    #include
    using namespace std;

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

    cout<<"Number of digits: "<<i;

    return 0;
    }

    ReplyDelete
    Replies
    1. Please delete the previous comment, did the mistake beforehand

      ID:201720097

      #include
      using namespace std;

      class integer{
      public:
      int number;
      void getinput(){
      cin>>number;
      }
      };

      class count : public integer {
      public:
      int volume(){
      int i=0;
      while(number>0){

      number=number/10;
      i++;
      }
      return i;
      }
      };
      int main()
      {
      count p;
      cout<<"Enter a number :\n";
      p.getinput();
      cout<<"Number of Digits : "<<p.volume();
      return 0;
      }

      Delete
  18. /*Taslima Akter
    ID-201720079
    Batch-55
    program-count digit of an integer number.
    */


    #include
    using namespace std;
    class digit
    {
    public:


    void getinput(int a)
    {
    num=a;
    }

    protected:
    int num;
    };
    class temp:public digit
    {
    public:

    int data()
    {
    int n=0;
    while(num>0)
    {
    num=num/10;
    n++;
    }
    return n;
    }

    };
    int main()
    {

    temp obj;
    int y;
    cout<<"enter the number:";
    cin>>y;
    obj.getinput(y);
    cout<<obj.data();
    return 0;
    }

    ReplyDelete
  19. //Taslima Akter
    ID-201720079
    Batch-55//

    program-count digit of an integer number.
    #include
    using namespace std;
    class digit
    {
    public:


    void getinput(int a)
    {
    num=a;
    }

    protected:
    int num;
    };
    class temp:public digit
    {
    public:

    int data()
    {
    int n=0;
    while(num>0)
    {
    num=num/10;
    n++;
    }
    return n;
    }

    };
    int main()
    {

    temp obj;
    int y;
    cout<<"enter the number:";
    cin>>y;
    obj.getinput(y);
    cout<<obj.data();
    return 0;
    }

    ReplyDelete
  20. //Taslima Akter
    ID-201720079
    Batch-55//

    program-count digit of an integer number.
    #include
    using namespace std;
    class digit
    {
    public:


    void getinput(int a)
    {
    num=a;
    }

    protected:
    int num;
    };
    class temp:public digit
    {
    public:

    int data()
    {
    int n=0;
    while(num>0)
    {
    num=num/10;
    n++;
    }
    return n;
    }

    };
    int main()
    {

    temp obj;
    int y;
    cout<<"enter the number:";
    cin>>y;
    obj.getinput(y);
    cout<<obj.data();
    return 0;
    }

    ReplyDelete
  21. Sorry sir, 1st er ta ami single inheritance chara koresilam. ekhon notun kore single inheritance diye submit korlam.
    ---------------------------------
    Name: Md. Johorul islam
    ID: 201720237
    Batch: 55 Diploma, Section : B
    ----------------------------------------------
    #include
    using namespace std;

    class jewel{
    public:
    int i=0, start;
    int myway()
    {
    cout<<"Please enter a number: \n";
    cin>> start;
    while (start>0)
    {
    start=start/10;
    i++;
    }
    return i;

    }

    };
    class sohel: public jewel{
    public:


    int getway()
    {


    }


    };
    int main()
    {
    sohel object;
    cout<<"The Number of digits is : "<<object.myway();


    }

    ReplyDelete
  22. Name: Md. Johorul islam
    ID: 201720237
    Batch: 55 Diploma, Section : B
    ----------------------------------------------
    #include
    using namespace std;

    class jewel{
    public:
    int i=0, start;
    int myway()
    {
    cout<<"Please enter a number: \n";
    cin>> start;
    while (start>0)
    {
    start=start/10;
    i++;
    }
    return i;

    }

    };
    class sohel: public jewel{
    public:


    int getway()
    {


    }


    };
    int main()
    {
    sohel object;
    cout<<"The Number of digits is : "<<object.myway();


    }

    ReplyDelete
  23. Sany Ahmed
    201720287
    55th Batch

    #include

    using namespace std;

    class mahi{
    public:
    int k;
    void getin(){
    cin>>k;
    }
    };

    class plc : public mahi {
    public:
    int newin(){
    int count=0;
    while(k>0){
    k=k/10;
    count++;
    }

    return count;
    }

    };



    int main()
    {
    plc obj;
    cout<<"Please Enter A Number : ";
    obj.getin();
    cout<<"Total Number : "<<obj.newin();
    return 0;
    }

    ReplyDelete
  24. //Taslima Akter
    ID-201720079
    Batch-55//

    program-count digit of an integer number.
    #include
    using namespace std;
    class digit
    {
    public:


    void getinput(int a)
    {
    num=a;
    }

    protected:
    int num;
    };
    class temp:public digit
    {
    public:

    int data()
    {
    int n=0;
    while(num>0)
    {
    num=num/10;
    n++;
    }
    return n;
    }

    };
    int main()
    {

    temp obj;
    int y;
    cout<<"enter the number:";
    cin>>y;
    obj.getinput(y);
    cout<<obj.data();
    return 0;
    }

    ReplyDelete
  25. //Taslima Akter
    ID-201720079
    Batch-55//

    program-count digit of an integer number.
    #include
    using namespace std;
    class digit
    {
    public:


    void getinput(int a)
    {
    num=a;
    }

    protected:
    int num;
    };
    class temp:public digit
    {
    public:

    int data()
    {
    int n=0;
    while(num>0)
    {
    num=num/10;
    n++;
    }
    return n;
    }

    };
    int main()
    {

    temp obj;
    int y;
    cout<<"enter the number:";
    cin>>y;
    obj.getinput(y);
    cout<<obj.data();
    return 0;
    }

    ReplyDelete
  26. -----------------------
    Fazle Rabbi Khan Taron
    ID : 201720263
    Batch: 55th
    -----------------------
    #include
    using namespace std;
    class count
    {
    public:


    void num(int a)
    {
    b=a;
    }

    protected:
    int b;
    };
    class prob:public count
    {
    public:

    int temp()
    {
    int z=0;
    while(b>0)
    {
    b=b/10;
    z++;
    }
    return z;
    }

    };
    int main()
    {

    prob obj;
    int x;
    cout<<"enter the number:";
    cin>>x;
    obj.num(x);
    cout<<obj.temp();
    return 0;
    }

    ReplyDelete
  27. /******************
    * Khorshed Alam *
    * CSE-56th *
    * ID: 201730438 *
    ******************/

    #include <iostream>
    using namespace std;

    class counter
    {
    public:
    int a = 0;
    int number(int x)
    {
    while(x>0)
    {
    x = x/10;
    a++;
    }
    return a;
    }

    };

    class math:public counter
    {
    public:
    int x;
    int getval()
    {
    cout<<"Input a number to calculate digit ";
    cin>>x;
    return x;
    }

    };

    int main()
    {
    math m;
    int x = m.getval();
    cout<<"This number contains = "<<m.number(x)<<" digits";

    }

    ReplyDelete
  28. Yousuf Ahmmed
    Batch: 56th
    Roll: 201730047

    #include
    using namespace std;

    class counter
    {
    public:
    int a = 0;
    int number(int z)
    {
    while(z>0)
    {
    z = z/10;
    d++;
    }
    return d;
    }

    };

    class math:public counter
    {
    public:
    int z;
    int getval()
    {
    cout<<"Input a number to calculate digit ";
    cin>>z;
    return z;
    }

    };

    int main()
    {
    math m;
    int z = m.getval();
    cout<<"This number contains = "<<m.number(z)<<" digits";

    }

    ReplyDelete
  29. /*Ariful Islam
    ID: 201730750
    AUB CSE 56th Batch*/

    #include
    using namespace std;

    class counter
    {
    public:
    int n = 0;
    int number(int i)
    {
    while(i>0)
    {
    i = i/10;
    n++;
    }
    return n;
    }

    };

    class math:public counter
    {
    public:
    int i;
    int getval()
    {
    cout<<"Input a number to calculate digit ";
    cin>>i;
    return i;
    }

    };

    int main()
    {
    math m;
    int i = m.getval();
    cout<<"This number contains = "<<m.number(i)<<" digits";

    }

    ReplyDelete
  30. /*Ariful Islam
    ID: 201730750
    AUB CSE 56th Batch*/

    #include
    using namespace std;

    class counter
    {
    public:
    int n = 0;
    int number(int i)
    {
    while(i>0)
    {
    i = i/10;
    n++;
    }
    return n;
    }

    };

    class math:public counter
    {
    public:
    int i;
    int getval()
    {
    cout<<"Input a number to calculate digit ";
    cin>>i;
    return i;
    }

    };

    int main()
    {
    math m;
    int i = m.getval();
    cout<<"This number contains = "<<m.number(i)<<" digits";

    }

    ReplyDelete
  31. #include
    using namespace std;
    class digit{
    public:
    int a;
    int getnum(){
    cout<<"Enter your Digits :";
    cin>>a;

    }

    };
    class count: public digit{
    public:

    int b=0;
    int check(){
    while(a>0){
    a=a/10;
    b++;
    }
    return b;
    }


    };

    int main()

    {
    int result;
    count obj;

    obj. getnum();
    cout<<"Total Digit :"<<obj.check();


    }

    ReplyDelete
  32. Al Hasan
    ID:201730011
    CSE: 56th
    --------------

    #include
    using namespace std;

    class counter
    {
    public:
    int a = 0;
    int number(int x)
    {
    while(x>0)
    {
    x = x/10;
    a++;
    }
    return a;
    }

    };

    class math:public counter
    {
    public:
    int x;
    int getval()
    {
    cout<<"Input a number to calculate digit ";
    cin>>x;
    return x;
    }

    };

    int main()
    {
    math m;
    int x = m.getval();
    cout<<"This number contains = "<<m.number(x)<<" digits";

    }

    ReplyDelete

Comment Here