diff --git a/20211018/break-1.c b/20211018/break-1.c new file mode 100644 index 0000000000000000000000000000000000000000..f3ee1a8199e63ce57a7624796af5e9f91917b614 --- /dev/null +++ b/20211018/break-1.c @@ -0,0 +1,16 @@ +#include <stdio.h> + +int main (void) +{ + int a = 0; + int b = 1; + printf ("%d\n", b); + for (int i = 0; i < 10; i++) + { + int c = a + b; + a = b; + b = c; + printf ("%d\n", b); + } + return 0; +} diff --git a/20211018/break-2.c b/20211018/break-2.c new file mode 100644 index 0000000000000000000000000000000000000000..061092d844651f831ceeee60efc0f2d1d3b84698 --- /dev/null +++ b/20211018/break-2.c @@ -0,0 +1,23 @@ +#include <stdio.h> + +/* Aufgabe: Finde die erste Fibonacci-Zahl, die größer ist als 10. */ + +int main (void) +{ + int a = 0; + int b = 1; + while (1) + { + int c = a + b; + a = b; + b = c; + if (b > 10) + { + printf ("Die erste Fibonacci-Zahl, die größer ist als 10, lautet: %d\n", b); + /* Dieses printf() erfolgt von der Logik her nach der Schleife, + es steht aber im Quelltext _innerhalb_ der Schleife. */ + break; + } + } + return 0; +} diff --git a/20211018/break-3.c b/20211018/break-3.c new file mode 100644 index 0000000000000000000000000000000000000000..676b6bc8506264873acb441a6b44e1632c22a257 --- /dev/null +++ b/20211018/break-3.c @@ -0,0 +1,17 @@ +#include <stdio.h> + +/* Aufgabe: Finde die erste Fibonacci-Zahl, die größer ist als 10. */ + +int main (void) +{ + int a = 0; + int b = 1; + while (b <= 10) + { + int c = a + b; + a = b; + b = c; + } + printf ("Die erste Fibonacci-Zahl, die größer ist als 10, lautet: %d\n", b); /* nach der Schleife */ + return 0; +}