0

How to print numbers 1 to 10 in reverse order?

plz frnds tell me

27th Sep 2017, 4:12 PM
Abhay Pratap Singh
Abhay Pratap Singh - avatar
5 Answers
+ 4
If this is homework, don't stop at copy, learn. #include <iostream> using namespace std; int main() { for(int i=10;i>0;i--) { cout << i << " "; } return 0; } Hth, cmiiw
27th Sep 2017, 4:25 PM
Ipang
+ 3
#include <cstdio> int main(){ puts("10 9 8 7 6 5 4 3 2 1"); return 0; } // One of the mooost efficient way to do so
27th Sep 2017, 6:43 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 3
void backwards(int i) { if (i == 1) { cout << i << " "; return; } cout << i << " "; backwards(i - 1); } int main() { backwards(10); cout << endl; return 0; }
28th Sep 2017, 2:06 AM
Zeke Williams
Zeke Williams - avatar
+ 3
@Zeke, recursion is all good! :D
28th Sep 2017, 2:35 AM
Ipang
+ 2
Haha I thought, let's make this more complicated than it needs to be
28th Sep 2017, 4:13 AM
Zeke Williams
Zeke Williams - avatar