Need help on displaying factors of an input number in a decreasing order.

I still can't figure out how to display the factors backwards. Tried playing with the algorithms but ending up with errors. lol. Please someone help me.

#include <iostream>
using namespace std;



int main ()
{


int counter;
int fnum;

cout<<" Please input a number and press [ENTER].";
cin>>fnum;

for (counter=1;counter<=fnum;counter++)
{if (fnum%counter==0)
cout<<counter<<endl;
}
return 0;
}


For example , If I input 36 , and the output would be 1 , 2 , 3 , 4 , 6 , 9 , 12 , 18 , 36. But how can i make it to display the other way around?
Last edited on
for ( counter=fnum; counter>0; counter-- )
Last edited on
Reverse the order of your loop?
oh thanks alot lowestOne! got it workin now.

@PanGalactic yeah. Anyways , its working now. Thanks guys.
Topic archived. No new replies allowed.