Write a C program that prompts for an integer greater than o
Write a C++ program that prompts for an integer greater than one that represents the low end of a range and a second integer greater than or equal to the first integer that represents the high end of a range. The program will print the factors of integers in this range in descending order.
For example, if the user enters 2 for the low end of the range and 6 for the high end of the range, then the program will output:
6: 6, 3, 2, 1
5: 5, 1
4: 4, 2, 1
3: 3, 1
2: 2 , 1
Solution
//Program and output is given below
#include <iostream>
using namespace std;
int main()
 {
    int low,high; //low for low end and high for high end
    int i,j;
    //prompt and accept low end and high end from user
    cout<<\"Enter low end of range (Greater than one):\";
    cin>>low;
    cout<<\"Enter high end of range (greater than or equal to low end):\";
    cin>>high;
    for(i=high;i>=low;i--)     //for loop for printing numbers from high to low
    {
        cout<<i<<\":\";
   //for loop for finding factor of number
        for(j=i;j>=1;j--)
        {
            if(i%j==0)
            cout<<j<<\",\";
        }
        cout<<endl;
    }
 
    return 0;
 }
/*Output
Enter low end of range (Greater than one):2
Enter high end of range (greater than or equal to low end):6
6:6,3,2,1,
5:5,1,
4:4,2,1,
3:3,1,
2:2,1,


