{
        int input;

        cout<<"Please select a number from 0 to 127: ";
        cin>>input;

        if (input<127 && input>0)
            MarkNumber(input);

        else
            cout<<"Please enter a number from 0 and 127!"<<endl;
    }

void MarkNumber(int input)
        {
            int loop=0, n=0;

            while (loop!=input)
            {
                cout<<n;
                n++;                //incrementing number from 0
                loop++;           //incrementing counter for loop
            }
            
            cout<<endl<<endl;
        }

I need to use only numbers from 0-9. SO if the user inputs 13, the output should be 01234567890123 (repeating the 0-9) instead of 012345678910111213.

Any help is appreciated!

Member Avatar for iamthwee

Have two counts.

The main count will count up to the number entered by the user.

The other count will count up in tens. Once ten is reached you can reset this count back to zero and continue.

Modify your MarkNumber as shown below.

void MarkNumber(int input)
        {
            int loop=input ;
            while (loop >= 10)
            {
                cout<<"0123456789";
                loop -= 10;
            }
   int n = input%10;
   for(int k = 0;k<n;k++)
    cout<<k;

            
            cout<<endl<<endl;
        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.