50

# BASIC C++

Humorous lightning talk at ACCU 2017 and Sweden CPP Stockholm showing how to write BASIC in C++ April 26, 2017

## Transcript

1. ACCU 2017
BASIC
BASIC
C++
C++
Björn Fahller

2. ACCU 2017

3. ACCU 2017

4. ACCU 2017
B A S I C !

5. ACCU 2017
10 PRINT “BASIC ROXXORS!!!”
20 GOTO 10

6. ACCU 2017
10 LET MAX=10
20 LET X = 0
30 GOTO 60
40 X = INT(RND(1)*(MAX-1) + 1)
50 RETURN
60 GOSUB 40
70 LET TIMES=0
80 LET GUESS=0
90 LET MAXGUESS = 5
100 PRINT "Guess a number between 1 and ", MAX
110 FOR TIMES = 1 TO MAXGUESS
120 INPUT GUESS
130 IF GUESS == X THEN GOTO 220
140 LET RELATIVE="big"
150 IF GUESS > X THEN GOTO 170
160 RELATIVE = "small"
170 PRINT "Too ", RELATIVE
180 NEXT
190 PRINT "Fail after ", MAXGUESS, " tries"
200 PRINT "The number is ", X
210 GOTO 230
220 PRINT "Only ", TIMES, " guesses. Well done!"
230 LET RETRY = "N"
240 INPUT "Want to try again (Y/N)?", RETRY
250 IF RETRY=="Y"||RETRY=="y" THEN GOTO 60

7. ACCU 2017
10 LET MAX=10
20 LET X = 0
30 GOTO 60
40 X = INT(RND(1)*(MAX-1) + 1)
50 RETURN
60 GOSUB 40
70 LET TIMES=0
80 LET GUESS=0
90 LET MAXGUESS = 5
100 PRINT "Guess a number between 1 and ", MAX
110 FOR TIMES = 1 TO MAXGUESS
120 INPUT GUESS
130 IF GUESS == X THEN GOTO 220
140 LET RELATIVE="big"
150 IF GUESS > X THEN GOTO 170
160 RELATIVE = "small"
170 PRINT "Too ", RELATIVE
180 NEXT
190 PRINT "Fail after ", MAXGUESS, " tries"
200 PRINT "The number is ", X
210 GOTO 230
220 PRINT "Only ", TIMES, " guesses. Well done!"
230 LET RETRY = "N"
240 INPUT "Want to try again (Y/N)?", RETRY
250 IF RETRY=="Y"||RETRY=="y" THEN GOTO 60

8. ACCU 2017
Function getting a random number
10 LET MAX=10
20 LET X = 0
30 GOTO 60
40 X = INT(RND(1)*(MAX-1) + 1)
50 RETURN
60 GOSUB 40
70 LET TIMES=0
80 LET GUESS=0
90 LET MAXGUESS = 5
100 PRINT "Guess a number between 1 and ", MAX
110 FOR TIMES = 1 TO MAXGUESS
120 INPUT GUESS
130 IF GUESS == X THEN GOTO 220
140 LET RELATIVE="big"
150 IF GUESS > X THEN GOTO 170
160 RELATIVE = "small"
170 PRINT "Too ", RELATIVE
180 NEXT
190 PRINT "Fail after ", MAXGUESS, " tries"
200 PRINT "The number is ", X
210 GOTO 230
220 PRINT "Only ", TIMES, " guesses. Well done!"
230 LET RETRY = "N"
240 INPUT "Want to try again (Y/N)?", RETRY
250 IF RETRY=="Y"||RETRY=="y" THEN GOTO 60

9. ACCU 2017
Function getting a random number
10 LET MAX=10
20 LET X = 0
30 GOTO 60
40 X = INT(RND(1)*(MAX-1) + 1)
50 RETURN
60 GOSUB 40
70 LET TIMES=0
80 LET GUESS=0
90 LET MAXGUESS = 5
100 PRINT "Guess a number between 1 and ", MAX
110 FOR TIMES = 1 TO MAXGUESS
120 INPUT GUESS
130 IF GUESS == X THEN GOTO 220
140 LET RELATIVE="big"
150 IF GUESS > X THEN GOTO 170
160 RELATIVE = "small"
170 PRINT "Too ", RELATIVE
180 NEXT
190 PRINT "Fail after ", MAXGUESS, " tries"
200 PRINT "The number is ", X
210 GOTO 230
220 PRINT "Only ", TIMES, " guesses. Well done!"
230 LET RETRY = "N"
240 INPUT "Want to try again (Y/N)?", RETRY
250 IF RETRY=="Y"||RETRY=="y" THEN GOTO 60

10. ACCU 2017
Function getting a random number
For loop
10 LET MAX=10
20 LET X = 0
30 GOTO 60
40 X = INT(RND(1)*(MAX-1) + 1)
50 RETURN
60 GOSUB 40
70 LET TIMES=0
80 LET GUESS=0
90 LET MAXGUESS = 5
100 PRINT "Guess a number between 1 and ", MAX
110 FOR TIMES = 1 TO MAXGUESS
120 INPUT GUESS
130 IF GUESS == X THEN GOTO 220
140 LET RELATIVE="big"
150 IF GUESS > X THEN GOTO 170
160 RELATIVE = "small"
170 PRINT "Too ", RELATIVE
180 NEXT
190 PRINT "Fail after ", MAXGUESS, " tries"
200 PRINT "The number is ", X
210 GOTO 230
220 PRINT "Only ", TIMES, " guesses. Well done!"
230 LET RETRY = "N"
240 INPUT "Want to try again (Y/N)?", RETRY
250 IF RETRY=="Y"||RETRY=="y" THEN GOTO 60

11. ACCU 2017
Function getting a random number
For loop
Output is trivial!
10 LET MAX=10
20 LET X = 0
30 GOTO 60
40 X = INT(RND(1)*(MAX-1) + 1)
50 RETURN
60 GOSUB 40
70 LET TIMES=0
80 LET GUESS=0
90 LET MAXGUESS = 5
100 PRINT "Guess a number between 1 and ", MAX
110 FOR TIMES = 1 TO MAXGUESS
120 INPUT GUESS
130 IF GUESS == X THEN GOTO 220
140 LET RELATIVE="big"
150 IF GUESS > X THEN GOTO 170
160 RELATIVE = "small"
170 PRINT "Too ", RELATIVE
180 NEXT
190 PRINT "Fail after ", MAXGUESS, " tries"
200 PRINT "The number is ", X
210 GOTO 230
220 PRINT "Only ", TIMES, " guesses. Well done!"
230 LET RETRY = "N"
240 INPUT "Want to try again (Y/N)?", RETRY
250 IF RETRY=="Y"||RETRY=="y" THEN GOTO 60

12. ACCU 2017
For loop
Output is trivial!
Function getting a random number
And so is input
10 LET MAX=10
20 LET X = 0
30 GOTO 60
40 X = INT(RND(1)*(MAX-1) + 1)
50 RETURN
60 GOSUB 40
70 LET TIMES=0
80 LET GUESS=0
90 LET MAXGUESS = 5
100 PRINT "Guess a number between 1 and ", MAX
110 FOR TIMES = 1 TO MAXGUESS
120 INPUT GUESS
130 IF GUESS == X THEN GOTO 220
140 LET RELATIVE="big"
150 IF GUESS > X THEN GOTO 170
160 RELATIVE = "small"
170 PRINT "Too ", RELATIVE
180 NEXT
190 PRINT "Fail after ", MAXGUESS, " tries"
200 PRINT "The number is ", X
210 GOTO 230
220 PRINT "Only ", TIMES, " guesses. Well done!"
230 LET RETRY = "N"
240 INPUT "Want to try again (Y/N)?", RETRY
250 IF RETRY=="Y"||RETRY=="y" THEN GOTO 60

13. ACCU 2017
For loop
Output is trivial!
Function getting a random number
And so is input
10 LET MAX=10
20 LET X = 0
30 GOTO 60
40 X = INT(RND(1)*(MAX-1) + 1)
50 RETURN
60 GOSUB 40
70 LET TIMES=0
80 LET GUESS=0
90 LET MAXGUESS = 5
100 PRINT "Guess a number between 1 and ", MAX
110 FOR TIMES = 1 TO MAXGUESS
120 INPUT GUESS
130 IF GUESS == X THEN GOTO 220
140 LET RELATIVE="big"
150 IF GUESS > X THEN GOTO 170
160 RELATIVE = "small"
170 PRINT "Too ", RELATIVE
180 NEXT
190 PRINT "Fail after ", MAXGUESS, " tries"
200 PRINT "The number is ", X
210 GOTO 230
220 PRINT "Only ", TIMES, " guesses. Well done!"
230 LET RETRY = "N"
240 INPUT "Want to try again (Y/N)?", RETRY
250 IF RETRY=="Y"||RETRY=="y" THEN GOTO 60
Highly visible control flow
without looking up names

14. ACCU 2017
For loop
Output is trivial!
And so is input
Function getting a random number
10 LET MAX=10
20 LET X = 0
30 GOTO 60
40 X = INT(RND(1)*(MAX-1) + 1)
50 RETURN
60 GOSUB 40
70 LET TIMES=0
80 LET GUESS=0
90 LET MAXGUESS = 5
100 PRINT "Guess a number between 1 and ", MAX
110 FOR TIMES = 1 TO MAXGUESS
120 INPUT GUESS
130 IF GUESS == X THEN GOTO 220
140 LET RELATIVE="big"
150 IF GUESS > X THEN GOTO 170
160 RELATIVE = "small"
170 PRINT "Too ", RELATIVE
180 NEXT
190 PRINT "Fail after ", MAXGUESS, " tries"
200 PRINT "The number is ", X
210 GOTO 230
220 PRINT "Only ", TIMES, " guesses. Well done!"
230 LET RETRY = "N"
240 INPUT "Want to try again (Y/N)?", RETRY
250 IF RETRY=="Y"||RETRY=="y" THEN GOTO 60
No tabs vs. spaces

15. ACCU 2017
For loop
Output is trivial!
Function getting a random number
And so is input
10 LET MAX=10
20 LET X = 0
30 GOTO 60
40 X = INT(RND(1)*(MAX-1) + 1)
50 RETURN
60 GOSUB 40
70 LET TIMES=0
80 LET GUESS=0
90 LET MAXGUESS = 5
100 PRINT "Guess a number between 1 and ", MAX
110 FOR TIMES = 1 TO MAXGUESS
120 INPUT GUESS
130 IF GUESS == X THEN GOTO 220
140 LET RELATIVE="big"
150 IF GUESS > X THEN GOTO 170
160 RELATIVE = "small"
170 PRINT "Too ", RELATIVE
180 NEXT
190 PRINT "Fail after ", MAXGUESS, " tries"
200 PRINT "The number is ", X
210 GOTO 230
220 PRINT "Only ", TIMES, " guesses. Well done!"
230 LET RETRY = "N"
240 INPUT "Want to try again (Y/N)?", RETRY
250 IF RETRY=="Y"||RETRY=="y" THEN GOTO 60
No tabs vs. spaces
No snake_case vs CamelCase

16. ACCU 2017
For loop
Output is trivial!
Function getting a random number
And so is input
10 LET MAX=10
20 LET X = 0
30 GOTO 60
40 X = INT(RND(1)*(MAX-1) + 1)
50 RETURN
60 GOSUB 40
70 LET TIMES=0
80 LET GUESS=0
90 LET MAXGUESS = 5
100 PRINT "Guess a number between 1 and ", MAX
110 FOR TIMES = 1 TO MAXGUESS
120 INPUT GUESS
130 IF GUESS == X THEN GOTO 220
140 LET RELATIVE="big"
150 IF GUESS > X THEN GOTO 170
160 RELATIVE = "small"
170 PRINT "Too ", RELATIVE
180 NEXT
190 PRINT "Fail after ", MAXGUESS, " tries"
200 PRINT "The number is ", X
210 GOTO 230
220 PRINT "Only ", TIMES, " guesses. Well done!"
230 LET RETRY = "N"
240 INPUT "Want to try again (Y/N)?", RETRY
250 IF RETRY=="Y"||RETRY=="y" THEN GOTO 60
No tabs vs. spaces
No snake_case vs CamelCase
No naming of functions or types

17. ACCU 2017
10 LET MAX=10
20 LET X = 0
30 GOTO 60
40 X = INT(RND(1)*(MAX-1) + 1)
50 RETURN
60 GOSUB 40
70 LET TIMES=0
80 LET GUESS=0
90 LET MAXGUESS = 5
100 PRINT "Guess a number between 1 and ", MAX
110 FOR TIMES = 1 TO MAXGUESS
120 INPUT GUESS
130 IF GUESS == X THEN GOTO 220
140 LET RELATIVE="big"
150 IF GUESS > X THEN GOTO 170
160 RELATIVE = "small"
170 PRINT "Too ", RELATIVE
180 NEXT
190 PRINT "Fail after ", MAXGUESS, " tries"
200 PRINT "The number is ", X
210 GOTO 230
220 PRINT "Only ", TIMES, " guesses. Well done!"
230 LET RETRY = "N"
240 INPUT "Want to try again (Y/N)?", RETRY
250 IF RETRY=="Y"||RETRY=="y" THEN GOTO 60

18. ACCU 2017
#include
int main() {
_10: LET MAX=10;
_20: LET X = 0;
_30: GOTO _60;
_40: X = INT(RND(1)*(MAX-1) + 1);
_50: RETURN;
_60: GOSUB _40;
_70: LET TIMES=0;
_80: LET GUESS=0;
_90: LET MAXGUESS = 5;
_100:PRINT "Guess a number between 1 and ", MAX;
_110:FOR TIMES = 1 TO MAXGUESS;
_120:INPUT GUESS;
_130:IF GUESS == X THEN GOTO _220;
_140:LET RELATIVE="big";
_150:IF GUESS > X THEN GOTO _170;
_160:RELATIVE = "small";
_170:PRINT "Too ", RELATIVE;
_180:NEXT;
_190:PRINT "Fail after ", MAXGUESS, " tries";
_200:PRINT "The number is ", X;
_210:GOTO _230;
_220:PRINT "Only ", TIMES, " guesses. Well done!";
_230:LET RETRY = "N";
_240:INPUT "Want to try again (Y/N)?", RETRY;
_250:IF RETRY=="Y"||RETRY=="y" THEN GOTO _60;
}

19. ACCU 2017
#include
int main() {
_10: LET MAX=10;
_20: LET X = 0;
_30: GOTO _60;
_40: X = INT(RND(1)*(MAX-1) + 1);
_50: RETURN;
_60: GOSUB _40;
_70: LET TIMES=0;
_80: LET GUESS=0;
_90: LET MAXGUESS = 5;
_100:PRINT "Guess a number between 1 and ", MAX;
_110:FOR TIMES = 1 TO MAXGUESS;
_120:INPUT GUESS;
_130:IF GUESS == X THEN GOTO _220;
_140:LET RELATIVE="big";
_150:IF GUESS > X THEN GOTO _170;
_160:RELATIVE = "small";
_170:PRINT "Too ", RELATIVE;
_180:NEXT;
_190:PRINT "Fail after ", MAXGUESS, " tries";
_200:PRINT "The number is ", X;
_210:GOTO _230;
_220:PRINT "Only ", TIMES, " guesses. Well done!";
_230:LET RETRY = "N";
_240:INPUT "Want to try again (Y/N)?", RETRY;
_250:IF RETRY=="Y"||RETRY=="y" THEN GOTO _60;
}

20. ACCU 2017
#include
int main() {
_10: LET MAX=10;
_20: LET X = 0;
_30: GOTO _60;
_40: X = INT(RND(1)*(MAX-1) + 1);
_50: RETURN;
_60: GOSUB _40;
_70: LET TIMES=0;
_80: LET GUESS=0;
_90: LET MAXGUESS = 5;
_100:PRINT "Guess a number between 1 and ", MAX;
_110:FOR TIMES = 1 TO MAXGUESS;
_120:INPUT GUESS;
_130:IF GUESS == X THEN GOTO _220;
_140:LET RELATIVE="big";
_150:IF GUESS > X THEN GOTO _170;
_160:RELATIVE = "small";
_170:PRINT "Too ", RELATIVE;
_180:NEXT;
_190:PRINT "Fail after ", MAXGUESS, " tries";
_200:PRINT "The number is ", X;
_210:GOTO _230;
_220:PRINT "Only ", TIMES, " guesses. Well done!";
_230:LET RETRY = "N";
_240:INPUT "Want to try again (Y/N)?", RETRY;
_250:IF RETRY=="Y"||RETRY=="y" THEN GOTO _60;
}

21. ACCU 2017
#include
int main() {
_10: LET MAX=10;
_20: LET X = 0;
_30: GOTO _60;
_40: X = INT(RND(1)*(MAX-1) + 1);
_50: RETURN;
_60: GOSUB _40;
_70: LET TIMES=0;
_80: LET GUESS=0;
_90: LET MAXGUESS = 5;
_100:PRINT "Guess a number between 1 and ", MAX;
_110:FOR TIMES = 1 TO MAXGUESS;
_120:INPUT GUESS;
_130:IF GUESS == X THEN GOTO _220;
_140:LET RELATIVE="big";
_150:IF GUESS > X THEN GOTO _170;
_160:RELATIVE = "small";
_170:PRINT "Too ", RELATIVE;
_180:NEXT;
_190:PRINT "Fail after ", MAXGUESS, " tries";
_200:PRINT "The number is ", X;
_210:GOTO _230;
_220:PRINT "Only ", TIMES, " guesses. Well done!";
_230:LET RETRY = "N";
_240:INPUT "Want to try again (Y/N)?", RETRY;
_250:IF RETRY=="Y"||RETRY=="y" THEN GOTO _60;
}

22. ACCU 2017
#include
int main() {
_10: LET MAX=10;
_20: LET X = 0;
_30: GOTO _60;
_40: X = INT(RND(1)*(MAX-1) + 1);
_50: RETURN;
_60: GOSUB _40;
_70: LET TIMES=0;
_80: LET GUESS=0;
_90: LET MAXGUESS = 5;
_100:PRINT "Guess a number between 1 and ", MAX;
_110:FOR TIMES = 1 TO MAXGUESS;
_120:INPUT GUESS;
_130:IF GUESS == X THEN GOTO _220;
_140:LET RELATIVE="big";
_150:IF GUESS > X THEN GOTO _170;
_160:RELATIVE = "small";
_170:PRINT "Too ", RELATIVE;
_180:NEXT;
_190:PRINT "Fail after ", MAXGUESS, " tries";
_200:PRINT "The number is ", X;
_210:GOTO _230;
_220:PRINT "Only ", TIMES, " guesses. Well done!";
_230:LET RETRY = "N";
_240:INPUT "Want to try again (Y/N)?", RETRY;
_250:IF RETRY=="Y"||RETRY=="y" THEN GOTO _60;
}

23. ACCU 2017
#include
int main() {
_10: LET MAX=10;
_20: LET X = 0;
_30: GOTO _60;
_40: X = INT(RND(1)*(MAX-1) + 1);
_50: RETURN;
_60: GOSUB _40;
_70: LET TIMES=0;
_80: LET GUESS=0;
_90: LET MAXGUESS = 5;
_100:PRINT "Guess a number between 1 and ", MAX;
_110:FOR TIMES = 1 TO MAXGUESS;
_120:INPUT GUESS;
_130:IF GUESS == X THEN GOTO _220;
_140:LET RELATIVE="big";
_150:IF GUESS > X THEN GOTO _170;
_160:RELATIVE = "small";
_170:PRINT "Too ", RELATIVE;
_180:NEXT;
_190:PRINT "Fail after ", MAXGUESS, " tries";
_200:PRINT "The number is ", X;
_210:GOTO _230;
_220:PRINT "Only ", TIMES, " guesses. Well done!";
_230:LET RETRY = "N";
_240:INPUT "Want to try again (Y/N)?", RETRY;
_250:IF RETRY=="Y"||RETRY=="y" THEN GOTO _60;
}

24. ACCU 2017
#include
int main() {
_10: LET MAX=10;
_20: LET X = 0;
_30: GOTO _60;
_40: X = INT(RND(1)*(MAX-1) + 1);
_50: RETURN;
_60: GOSUB _40;
_70: LET TIMES=0;
_80: LET GUESS=0;
_90: LET MAXGUESS = 5;
_100:PRINT "Guess a number between 1 and ", MAX;
_110:FOR TIMES = 1 TO MAXGUESS;
_120:INPUT GUESS;
_130:IF GUESS == X THEN GOTO _220;
_140:LET RELATIVE="big";
_150:IF GUESS > X THEN GOTO _170;
_160:RELATIVE = "small";
_170:PRINT "Too ", RELATIVE;
_180:NEXT;
_190:PRINT "Fail after ", MAXGUESS, " tries";
_200:PRINT "The number is ", X;
_210:GOTO _230;
_220:PRINT "Only ", TIMES, " guesses. Well done!";
_230:LET RETRY = "N";
_240:INPUT "Want to try again (Y/N)?", RETRY;
_250:IF RETRY=="Y"||RETRY=="y" THEN GOTO _60;
}

25. ACCU 2017
#include
int main() {
_10: LET MAX=10;
_20: LET X = 0;
_30: GOTO _60;
_40: X = INT(RND(1)*(MAX-1) + 1);
_50: RETURN;
_60: GOSUB _40;
_70: LET TIMES=0;
_80: LET GUESS=0;
_90: LET MAXGUESS = 5;
_100:PRINT "Guess a number between 1 and ", MAX;
_110:FOR TIMES = 1 TO MAXGUESS;
_120:INPUT GUESS;
_130:IF GUESS == X THEN GOTO _220;
_140:LET RELATIVE="big";
_150:IF GUESS > X THEN GOTO _170;
_160:RELATIVE = "small";
_170:PRINT "Too ", RELATIVE;
_180:NEXT;
_190:PRINT "Fail after ", MAXGUESS, " tries";
_200:PRINT "The number is ", X;
_210:GOTO _230;
_220:PRINT "Only ", TIMES, " guesses. Well done!";
_230:LET RETRY = "N";
_240:INPUT "Want to try again (Y/N)?", RETRY;
_250:IF RETRY=="Y"||RETRY=="y" THEN GOTO _60;
}

26. ACCU 2017
#include
int main() {
_10: LET MAX=10;
_20: LET X = 0;
_30: GOTO _60;
_40: X = INT(RND(1)*(MAX-1) + 1);
_50: RETURN;
_60: GOSUB _40;
_70: LET TIMES=0;
_80: LET GUESS=0;
_90: LET MAXGUESS = 5;
_100:PRINT "Guess a number between 1 and ", MAX;
_110:FOR TIMES = 1 TO MAXGUESS;
_120:INPUT GUESS;
_130:IF GUESS == X THEN GOTO _220;
_140:LET RELATIVE="big";
_150:IF GUESS > X THEN GOTO _170;
_160:RELATIVE = "small";
_170:PRINT "Too ", RELATIVE;
_180:NEXT;
_190:PRINT "Fail after ", MAXGUESS, " tries";
_200:PRINT "The number is ", X;
_210:GOTO _230;
_220:PRINT "Only ", TIMES, " guesses. Well done!";
_230:LET RETRY = "N";
_240:INPUT "Want to try again (Y/N)?", RETRY;
_250:IF RETRY=="Y"||RETRY=="y" THEN GOTO _60;
}

27. ACCU 2017
#include
int main() {
_10: LET MAX=10;
_20: LET X = 0;
_30: GOTO _60;
_40: X = INT(RND(1)*(MAX-1) + 1);
_50: RETURN;
_60: GOSUB _40;
_70: LET TIMES=0;
_80: LET GUESS=0;
_90: LET MAXGUESS = 5;
_100:PRINT "Guess a number between 1 and ", MAX;
_110:FOR TIMES = 1 TO MAXGUESS;
_120:INPUT GUESS;
_130:IF GUESS == X THEN GOTO _220;
_140:LET RELATIVE="big";
_150:IF GUESS > X THEN GOTO _170;
_160:RELATIVE = "small";
_170:PRINT "Too ", RELATIVE;
_180:NEXT;
_190:PRINT "Fail after ", MAXGUESS, " tries";
_200:PRINT "The number is ", X;
_210:GOTO _230;
_220:PRINT "Only ", TIMES, " guesses. Well done!";
_230:LET RETRY = "N";
_240:INPUT "Want to try again (Y/N)?", RETRY;
_250:IF RETRY=="Y"||RETRY=="y" THEN GOTO _60;
}

28. ACCU 2017
#include
int main() {
_10: LET MAX=10;
_20: LET X = 0;
_30: GOTO _60;
_40: X = INT(RND(1)*(MAX-1) + 1);
_50: RETURN;
_60: GOSUB _40;
_70: LET TIMES=0;
_80: LET GUESS=0;
_90: LET MAXGUESS = 5;
_100:PRINT "Guess a number between 1 and ", MAX;
_110:FOR TIMES = 1 TO MAXGUESS;
_120:INPUT GUESS;
_130:IF GUESS == X THEN GOTO _220;
_140:LET RELATIVE="big";
_150:IF GUESS > X THEN GOTO _170;
_160:RELATIVE = "small";
_170:PRINT "Too ", RELATIVE;
_180:NEXT;
_190:PRINT "Fail after ", MAXGUESS, " tries";
_200:PRINT "The number is ", X;
_210:GOTO _230;
_220:PRINT "Only ", TIMES, " guesses. Well done!";
_230:LET RETRY = "N";
_240:INPUT "Want to try again (Y/N)?", RETRY;
_250:IF RETRY=="Y"||RETRY=="y" THEN GOTO _60;
}

29. ACCU 2017
#include
int main() {
_10: LET MAX=10;
_20: LET X = 0;
_30: GOTO _60;
_40: X = INT(RND(1)*(MAX-1) + 1);
_50: RETURN;
_60: GOSUB _40;
_70: LET TIMES=0;
_80: LET GUESS=0;
_90: LET MAXGUESS = 5;
_100:PRINT "Guess a number between 1 and ", MAX;
_110:FOR TIMES = 1 TO MAXGUESS;
_120:INPUT GUESS;
_130:IF GUESS == X THEN GOTO _220;
_140:LET RELATIVE="big";
_150:IF GUESS > X THEN GOTO _170;
_160:RELATIVE = "small";
_170:PRINT "Too ", RELATIVE;
_180:NEXT;
_190:PRINT "Fail after ", MAXGUESS, " tries";
_200:PRINT "The number is ", X;
_210:GOTO _230;
_220:PRINT "Only ", TIMES, " guesses. Well done!";
_230:LET RETRY = "N";
_240:INPUT "Want to try again (Y/N)?", RETRY;
_250:IF RETRY=="Y"||RETRY=="y" THEN GOTO _60;
}

30. ACCU 2017
#include
int main() {
_10: LET MAX=10;
_20: LET X = 0;
_30: GOTO _60;
_40: X = INT(RND(1)*(MAX-1) + 1);
_50: RETURN;
_60: GOSUB _40;
_70: LET TIMES=0;
_80: LET GUESS=0;
_90: LET MAXGUESS = 5;
_100:PRINT "Guess a number between 1 and ", MAX;
_110:FOR TIMES = 1 TO MAXGUESS;
_120:INPUT GUESS;
_130:IF GUESS == X THEN GOTO _220;
_140:LET RELATIVE="big";
_150:IF GUESS > X THEN GOTO _170;
_160:RELATIVE = "small";
_170:PRINT "Too ", RELATIVE;
_180:NEXT;
_190:PRINT "Fail after ", MAXGUESS, " tries";
_200:PRINT "The number is ", X;
_210:GOTO _230;
_220:PRINT "Only ", TIMES, " guesses. Well done!";
_230:LET RETRY = "N";
_240:INPUT "Want to try again (Y/N)?", RETRY;
_250:IF RETRY=="Y"||RETRY=="y" THEN GOTO _60;
}

31. ACCU 2017
#include
int main() {
_10: LET MAX=10;
_20: LET X = 0;
_30: GOTO _60;
_40: X = INT(RND(1)*(MAX-1) + 1);
_50: RETURN;
_60: GOSUB _40;
_70: LET TIMES=0;
_80: LET GUESS=0;
_90: LET MAXGUESS = 5;
_100:PRINT "Guess a number between 1 and ", MAX;
_110:FOR TIMES = 1 TO MAXGUESS;
_120:INPUT GUESS;
_130:IF GUESS == X THEN GOTO _220;
_140:LET RELATIVE="big";
_150:IF GUESS > X THEN GOTO _170;
_160:RELATIVE = "small";
_170:PRINT "Too ", RELATIVE;
_180:NEXT;
_190:PRINT "Fail after ", MAXGUESS, " tries";
_200:PRINT "The number is ", X;
_210:GOTO _230;
_220:PRINT "Only ", TIMES, " guesses. Well done!";
_230:LET RETRY = "N";
_240:INPUT "Want to try again (Y/N)?", RETRY;
_250:IF RETRY=="Y"||RETRY=="y" THEN GOTO _60;
}

32. ACCU 2017
#include
int main() {
_10: LET MAX=10;
_20: LET X = 0;
_30: GOTO _60;
_40: X = INT(RND(1)*(MAX-1) + 1);
_50: RETURN;
_60: GOSUB _40;
_70: LET TIMES=0;
_80: LET GUESS=0;
_90: LET MAXGUESS = 5;
_100:PRINT "Guess a number between 1 and ", MAX;
_110:FOR TIMES = 1 TO MAXGUESS;
_120:INPUT GUESS;
_130:IF GUESS == X THEN GOTO _220;
_140:LET RELATIVE="big";
_150:IF GUESS > X THEN GOTO _170;
_160:RELATIVE = "small";
_170:PRINT "Too ", RELATIVE;
_180:NEXT;
_190:PRINT "Fail after ", MAXGUESS, " tries";
_200:PRINT "The number is ", X;
_210:GOTO _230;
_220:PRINT "Only ", TIMES, " guesses. Well done!";
_230:LET RETRY = "N";
_240:INPUT "Want to try again (Y/N)?", RETRY;
_250:IF RETRY=="Y"||RETRY=="y" THEN GOTO _60;
}

33. ACCU 2017
#include
int main() {
_10: LET MAX=10;
_20: LET X = 0;
_30: GOTO _60;
_40: X = INT(RND(1)*(MAX-1) + 1);
_50: RETURN;
_60: GOSUB _40;
_70: LET TIMES=0;
_80: LET GUESS=0;
_90: LET MAXGUESS = 5;
_100:PRINT "Guess a number between 1 and ", MAX;
_110:FOR TIMES = 1 TO MAXGUESS;
_120:INPUT GUESS;
_130:IF GUESS == X THEN GOTO _220;
_140:LET RELATIVE="big";
_150:IF GUESS > X THEN GOTO _170;
_160:RELATIVE = "small";
_170:PRINT "Too ", RELATIVE;
_180:NEXT;
_190:PRINT "Fail after ", MAXGUESS, " tries";
_200:PRINT "The number is ", X;
_210:GOTO _230;
_220:PRINT "Only ", TIMES, " guesses. Well done!";
_230:LET RETRY = "N";
_240:INPUT "Want to try again (Y/N)?", RETRY;
_250:IF RETRY=="Y"||RETRY=="y" THEN GOTO _60;
}

34. ACCU 2017
#include
int main() {
_10: LET MAX=10;
_20: LET X = 0;
_30: GOTO _60;
_40: X = INT(RND(1)*(MAX-1) + 1);
_50: RETURN;
_60: GOSUB _40;
_70: LET TIMES=0;
_80: LET GUESS=0;
_90: LET MAXGUESS = 5;
_100:PRINT "Guess a number between 1 and ", MAX;
_110:FOR TIMES = 1 TO MAXGUESS;
_120:INPUT GUESS;
_130:IF GUESS == X THEN GOTO _220;
_140:LET RELATIVE="big";
_150:IF GUESS > X THEN GOTO _170;
_160:RELATIVE = "small";
_170:PRINT "Too ", RELATIVE;
_180:NEXT;
_190:PRINT "Fail after ", MAXGUESS, " tries";
_200:PRINT "The number is ", X;
_210:GOTO _230;
_220:PRINT "Only ", TIMES, " guesses. Well done!";
_230:LET RETRY = "N";
_240:INPUT "Want to try again (Y/N)?", RETRY;
_250:IF RETRY=="Y"||RETRY=="y" THEN GOTO _60;
}

35. ACCU 2017
#include
int main() {
_10: LET MAX=10;
_20: LET X = 0;
_30: GOTO _60;
_40: X = INT(RND(1)*(MAX-1) + 1);
_50: RETURN;
_60: GOSUB _40;
_70: LET TIMES=0;
_80: LET GUESS=0;
_90: LET MAXGUESS = 5;
_100:PRINT "Guess a number between 1 and ", MAX;
_110:FOR TIMES = 1 TO MAXGUESS;
_120:INPUT GUESS;
_130:IF GUESS == X THEN GOTO _220;
_140:LET RELATIVE="big";
_150:IF GUESS > X THEN GOTO _170;
_160:RELATIVE = "small";
_170:PRINT "Too ", RELATIVE;
_180:NEXT;
_190:PRINT "Fail after ", MAXGUESS, " tries";
_200:PRINT "The number is ", X;
_210:GOTO _230;
_220:PRINT "Only ", TIMES, " guesses. Well done!";
_230:LET RETRY = "N";
_240:INPUT "Want to try again (Y/N)?", RETRY;
_250:IF RETRY=="Y"||RETRY=="y" THEN GOTO _60;
}
C++ today is as
simple as BASIC
was in the 80s!

36. ACCU 2017

https://github.com/rollbear/basicpp
{"ft_lang_label":"__label__en","ft_lang_prob":0.5935436,"math_prob":0.9653285,"size":21734,"snap":"2023-14-2023-23","text_gpt3_token_len":8620,"char_repetition_ratio":0.17040958,"word_repetition_ratio":0.96919554,"special_character_ratio":0.48200977,"punctuation_ratio":0.23510619,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99708796,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-03-23T19:05:04Z\",\"WARC-Record-ID\":\"<urn:uuid:906a3303-9b82-4566-ae19-ba349c53465f>\",\"Content-Length\":\"132192\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:efeae92f-7062-4d68-bf88-8c34453295b4>\",\"WARC-Concurrent-To\":\"<urn:uuid:99163fd8-13ce-4eb1-8a04-7b502370fb09>\",\"WARC-IP-Address\":\"104.22.38.239\",\"WARC-Target-URI\":\"https://speakerdeck.com/rollbear/basic-c-plus-plus\",\"WARC-Payload-Digest\":\"sha1:DU3567ERYLB2Q4OHWKBVX6MDZZ6OVEUU\",\"WARC-Block-Digest\":\"sha1:ID6S7EZI7PTVEVQMTMNLO7L2PXQCO67Z\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-14/CC-MAIN-2023-14_segments_1679296945182.12_warc_CC-MAIN-20230323163125-20230323193125-00522.warc.gz\"}"}