-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwhileloop.d
43 lines (39 loc) · 997 Bytes
/
whileloop.d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import std.stdio;
void main()
{
bool existsCookie = true;
int number = 10;
while (existsCookie && number != 0) {
writeln("Take cookie");
writeln("Eat cookie");
number -= 1;
}
while (number >= 0) {
write("Please enter a number: ");
readf(" %s", &number);
if (number == 13) {
writeln("Sorry, I'm not accepting that");
continue;
} else if (number == 42) {
writeln("FOUND IT");
break;
}
writeln("Thank you for ", number);
}
writeln("Exited the loop");
while (true) {
write("0:Exit, 1:Turkish, 2:English - Your choice? ");
int choice;
readf(" %s", &choice);
if (choice == 0) {
writeln("See you later aligator.");
break; // Will exit the loop
} else if (choice == 1) {
writeln("Merhaba!");
} else if (choice == 2) {
writeln("Hello!");
} else {
writeln("I don't know that... :/");
}
}
}