0
How to print numbers 1 to 10 in reverse order?
plz frnds tell me
5 Respostas
+ 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
+ 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
+ 3
void backwards(int i) {
if (i == 1) {
cout << i << " ";
return;
}
cout << i << " ";
backwards(i - 1);
}
int main() {
backwards(10);
cout << endl;
return 0;
}
+ 3
@Zeke, recursion is all good! :D
+ 2
Haha I thought, let's make this more complicated than it needs to be