Count digit from an integer number as per requirement

Write a C++ program which will count digit from an integer number. The input(integer number) must be given by user from keyboard. This program will ask to the user for number of test to count the digit.

For example:

Display: How many test you want to do:
input: 2

input: 3456
Display output: This is a 4 digit number
input:789
Display output: This is a 3 digit number

13 comments:

  1. Md.Nazrul Islam, ID:201630769January 22, 2017 at 3:30 AM

    #include
    using namespace std;
    int main()
    {
    int test_num,original_num,number,digit;
    original_num=0;
    digit=0;
    cout<<"How many test you want to do:";
    cin>>test_num;
    if(test_num>0)
    {
    while(test_num>0)
    {
    cout<<"\nEnter Integer Number:";
    cin>>number;
    original_num=number;
    while(number>0)
    {
    digit=digit+1;
    number/=10;
    }
    test_num=test_num-1;
    cout<<"The digit of "<<original_num<<" is: "<<digit;
    digit=0;
    }
    }
    return 0;
    }

    ReplyDelete
  2. #include
    using namespace std;
    int main()
    {
    int n,i,i1, i2, test1;
    cout << "How many test you want to do: ";
    cin >> n;
    if( n ){
    for(i=1; i<=n; ++i){
    cout << "Please Enter Your Test ID: ";
    cin >> test1;
    if(test1>=10){
    for( i1=0; test1>0; i1++){
    test1=test1/10;
    }
    cout << "This is a " << i1 << " digit number " << endl;
    }else{
    cout << "Sorry i am not calculate over than 10 Digit Please try agin";
    }
    };

    }else{
    cout << "try agin";
    }
    return 0;
    }

    ReplyDelete
  3. #include
    using namespace std;
    int main()
    {
    int n,i,i1, i2, test1;
    cout << "How many test you want to do: ";
    cin >> n;
    if( n ){
    for(i=1; i<=n; ++i){
    cout << "Please Enter Your Test ID: ";
    cin >> test1;
    if(test1>=10){
    for( i1=0; test1>0; i1++){
    test1=test1/10;
    }
    cout << "This is a " << i1 << " digit number " << endl;
    }else{
    cout << "Sorry i am not calculate over than 10 Digit Please try agin";
    }
    };

    }else{
    cout << "try agin";
    }
    return 0;
    }

    ReplyDelete
  4. #include
    using namespace std;
    int main()
    {
    int n, x, i1, i2, test1;
    x = 0;
    cout << "How many test you want to do: ";
    cin >> n;

    while(x <= 2) {
    cout << "Please Enter Your Test ID: ";
    cin >> test1;
    if(test1>=10){
    for( i1=0; test1>0; i1++){
    test1=test1/10;
    }
    cout << "This is a " << i1 << " digit number " << endl;
    }else{
    cout << "Please try agin";
    }
    x++;
    }


    return 0;
    }

    ReplyDelete
  5. #include
    using namespace std;
    int main()
    {
    int value1,value2 ,number,digit;
    value2=0;
    digit=0;
    cout<<"How many test you want to do:";
    cin>>value1;
    if(value1>0)
    {
    while(value1>0)
    {
    cout<<"\nEnter Integer Number:";
    cin>>number;
    value2=number;
    while(number>0)
    {
    digit=digit+1;
    number/=10;
    }
    value1=value1-1;
    cout<<"The digit of "<<value2<<" is: "<<digit;
    digit=0;
    }
    }
    return 0;
    }

    ReplyDelete
  6. //md.sumon Ahammed. id:201630483//
    #include

    using namespace std;

    int main()
    {

    ifstream fin;
    fin.open("out.txt");
    char ftn[30];
    int coun=0;
    while(!fin.eof()){
    fin.get line (str,30);
    count++;

    }
    count<<"The number of lince:"<<count;
    fin.close(;
    getch();
    return0;

    }

    ReplyDelete
  7. #include
    using namespace std;
    int main()
    {
    int n, x, i1, i2, test1;
    x = 0;
    cout << "How many test you want to do: ";
    cin >> n;

    while(x <= 2) {
    cout << "Please Enter Your Test ID: ";
    cin >> test1;
    if(test1>=10){
    for( i1=0; test1>0; i1++){
    test1=test1/10;
    }
    cout << "This is a " << i1 << " digit number " << endl;
    }else{
    cout << "Please try agin";
    }
    x++;
    }

    ReplyDelete
  8. #include

    using namespace std;

    int main()
    {

    ifstream fin;
    fin.open("out.txt");
    char ftn[30];
    int coun=0;
    while(!fin.eof()){
    fin.get line (str,30);
    count++;

    }
    count<<"The number of lince:"<<count;
    fin.close(;
    getch();
    return0;

    }

    ReplyDelete
  9. #include

    using namespace std;

    int main()
    {

    ifstream fin;
    fin.open("out.txt");
    char ftn[30];
    int coun=0;
    while(!fin.eof()){
    fin.get line (str,30);
    count++;

    }
    count<<"The number of lince:"<<count;
    fin.close(;
    getch();
    return0;

    }

    ReplyDelete

Comment Here