### 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.

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;
}

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;
}

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;
}

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;
}

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

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

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

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

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;
}

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<<
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;
}

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;
}

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;
}

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;
}

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;
}

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();
}

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

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

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;
}

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;
}

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;
}

15. This comment has been removed by the author.

16. /*******************************
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;
}

Roll : 201720297

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;
}

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;
}

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;
}

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;
}

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;
}

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()
{
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();

}

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()
{
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();

}

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;
}

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;
}

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;
}

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;
}

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";

}

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";

}

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";

}

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";

}

31. #include
using namespace std;
class digit{
public:
int a;
int getnum(){
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();

}

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";

}

Comment Here