Q:

Write a program that prompts the user for two integers. Print each number in the range specified by those two integers

0

Write a program that prompts the user for two integers.

Print each number in the range specified by those two integers.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <iostream>

int main()
{
    int small = 0, big = 0;
    std::cout << "please input two integers:";
    std::cin >> small >> big;

    if (small > big) {
        int tmp = small;
        small = big;
        big = tmp;
    }

    while (small <= big) {
        std::cout << small << " ";
        ++small;
    }
    std::cout << std::endl;

    return 0;
}

 

Output:

please input two integers:5
10
5 6 7 8 9 10

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now