+ 1

Can i use the if statement to

print a number from 1 to 9.. how plis help

16th Dec 2016, 5:40 PM
stephen haokip
stephen haokip - avatar
5 Answers
+ 4
for(int i=1;i<=9;i++){ cout<<i<<endl; }
16th Dec 2016, 6:08 PM
Dhruv Saxena
Dhruv Saxena - avatar
+ 2
int main(){ static int i=1; if(i<=9){ cout<<i<<endl; i++; main(); } return 0; }
16th Dec 2016, 6:19 PM
Dhruv Saxena
Dhruv Saxena - avatar
0
for(int i=1;i<10;i++) {cout<<i<<endl; }
16th Dec 2016, 5:46 PM
Leonida17st
Leonida17st - avatar
0
yes. using recursion. void foo(int n){ if(n<10){ cout<<n<<" "; foo(n+1); } else return; } call it as foo(1) from main()
16th Dec 2016, 6:19 PM
Caffeinated Gamer YT
Caffeinated Gamer YT - avatar
- 4
dumbass not using the for statement
16th Dec 2016, 6:13 PM
stephen haokip
stephen haokip - avatar