Home > Enterprise >  How can I remove the PERIOD before the number 1 in the output?
How can I remove the PERIOD before the number 1 in the output?

Time:09-21

cin >> i >> e;
    while ( i <= e){
            cout << "." << i;
            i = i   1;
}

Example: INPUT: 1 5 OUTPUT: .1.2.3.4.5
EXPECTED OUTPUT: 1.2.3.4.5

CodePudding user response:

I haven't tested it, but this should do what you're looking for.

int main( ) {
    int input{ 0 };
    int count{ 0 };

    std::cin >> input >> count;

    std::cout << input;
    while(   input <= count ) {
        std::cout << '.' << input;
    }
    std::cout << '\n';
}
  •  Tags:  
  • c
  • Related