+ 2

How I can print 1 to 100 without using loops in c/c++

19th Aug 2017, 7:23 AM
Rahul Aryan
Rahul Aryan - avatar
6 ответов
+ 4
@Tobias, that's a recursive function. Good idea.
19th Aug 2017, 8:09 AM
Dragon Slayer Xavier
Dragon Slayer Xavier - avatar
+ 3
https://code.sololearn.com/cwL2Wi2b97ZW/#cpp Using recurse to print. Interestingly, if you switch the cout and recurse it will change from descend to ascending; because the functions execution is then reversed.
19th Aug 2017, 12:15 PM
Mohammed Gaber
Mohammed Gaber - avatar
+ 2
What are loops used for? They print from 1 to 100, or reading all the lines from a file, or go through characters in a string. The reasons why we use loops is to help us with this very problem: Make recursive work, less work; Help us analise a ton of words without having to type 1000 lines of code. I would still recommend using a loop
19th Aug 2017, 7:55 AM
Limitless
Limitless - avatar
0
I don't know any option other than loops and direct printing.
19th Aug 2017, 7:29 AM
Dragon Slayer Xavier
Dragon Slayer Xavier - avatar
0
Type everything one by one
19th Aug 2017, 7:52 AM
LordGhostX
LordGhostX - avatar
- 4
only option is probably directly typing it up
19th Aug 2017, 7:51 AM
Kittiphat Paopeng