0
{
        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!

3
Contributors
2
Replies
3
Views
10 Years
Discussion Span
Last Post by dilip.mathews
0

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.

0

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;
        }
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.