From f447dadf2d4d8b484dd7a38a89cdedb158252a68 Mon Sep 17 00:00:00 2001 From: Peter Gerwinski <peter.gerwinski@hs-bochum.de> Date: Mon, 11 Oct 2021 21:33:16 +0200 Subject: [PATCH] Beispiel-Programme 11.10.2021 --- 20211011/functions-1.c | 17 ++++++++++++ 20211011/functions-10.c | 27 ++++++++++++++++++ 20211011/functions-11.c | 25 +++++++++++++++++ 20211011/functions-2.c | 12 ++++++++ 20211011/functions-3.c | 13 +++++++++ 20211011/functions-4.c | 14 ++++++++++ 20211011/functions-5.c | 14 ++++++++++ 20211011/functions-6.c | 26 ++++++++++++++++++ 20211011/functions-7.c | 27 ++++++++++++++++++ 20211011/functions-8.c | 27 ++++++++++++++++++ 20211011/functions-9.c | 27 ++++++++++++++++++ 20211011/hp-20211011.pdf | Bin 285350 -> 285364 bytes 20211011/hp-20211011.tex | 3 +- 20211011/pointers-1.c | 14 ++++++++++ 20211011/pointers-2.c | 14 ++++++++++ 20211011/pointers-3-O0.s | 55 +++++++++++++++++++++++++++++++++++++ 20211011/pointers-3-O1.s | 36 ++++++++++++++++++++++++ 20211011/pointers-3.c | 14 ++++++++++ 20211011/side-effects-1.c | 8 ++++++ 20211011/side-effects-10.c | 8 ++++++ 20211011/side-effects-11.c | 8 ++++++ 20211011/side-effects-12.c | 8 ++++++ 20211011/side-effects-13.c | 15 ++++++++++ 20211011/side-effects-14.c | 15 ++++++++++ 20211011/side-effects-15.c | 12 ++++++++ 20211011/side-effects-16.c | 13 +++++++++ 20211011/side-effects-17.c | 13 +++++++++ 20211011/side-effects-18.c | 13 +++++++++ 20211011/side-effects-19.c | 13 +++++++++ 20211011/side-effects-2.c | 8 ++++++ 20211011/side-effects-20.c | 13 +++++++++ 20211011/side-effects-3.c | 8 ++++++ 20211011/side-effects-4.c | 8 ++++++ 20211011/side-effects-5.c | 10 +++++++ 20211011/side-effects-6.c | 10 +++++++ 20211011/side-effects-7.c | 10 +++++++ 20211011/side-effects-8.c | 10 +++++++ 20211011/side-effects-9.c | 8 ++++++ 38 files changed, 575 insertions(+), 1 deletion(-) create mode 100644 20211011/functions-1.c create mode 100644 20211011/functions-10.c create mode 100644 20211011/functions-11.c create mode 100644 20211011/functions-2.c create mode 100644 20211011/functions-3.c create mode 100644 20211011/functions-4.c create mode 100644 20211011/functions-5.c create mode 100644 20211011/functions-6.c create mode 100644 20211011/functions-7.c create mode 100644 20211011/functions-8.c create mode 100644 20211011/functions-9.c create mode 100644 20211011/pointers-1.c create mode 100644 20211011/pointers-2.c create mode 100644 20211011/pointers-3-O0.s create mode 100644 20211011/pointers-3-O1.s create mode 100644 20211011/pointers-3.c create mode 100644 20211011/side-effects-1.c create mode 100644 20211011/side-effects-10.c create mode 100644 20211011/side-effects-11.c create mode 100644 20211011/side-effects-12.c create mode 100644 20211011/side-effects-13.c create mode 100644 20211011/side-effects-14.c create mode 100644 20211011/side-effects-15.c create mode 100644 20211011/side-effects-16.c create mode 100644 20211011/side-effects-17.c create mode 100644 20211011/side-effects-18.c create mode 100644 20211011/side-effects-19.c create mode 100644 20211011/side-effects-2.c create mode 100644 20211011/side-effects-20.c create mode 100644 20211011/side-effects-3.c create mode 100644 20211011/side-effects-4.c create mode 100644 20211011/side-effects-5.c create mode 100644 20211011/side-effects-6.c create mode 100644 20211011/side-effects-7.c create mode 100644 20211011/side-effects-8.c create mode 100644 20211011/side-effects-9.c diff --git a/20211011/functions-1.c b/20211011/functions-1.c new file mode 100644 index 0000000..181c578 --- /dev/null +++ b/20211011/functions-1.c @@ -0,0 +1,17 @@ +#include <stdio.h> + +int answer (void) +{ + return 42; +} + +void foo (void) +{ + printf ("%d\n", answer ()); +} + +int main (void) +{ + foo (); + return 0; +} diff --git a/20211011/functions-10.c b/20211011/functions-10.c new file mode 100644 index 0000000..cf4ed0e --- /dev/null +++ b/20211011/functions-10.c @@ -0,0 +1,27 @@ +#include <stdio.h> + +int a = 0; +int b = 3; + +void foo (void) +{ + b++; + static int a = 5; + int b = 7; + printf ("foo(): " "a = %d, b = %d\n", a, b); + a++; +} + +int main (void) +{ + printf ("main(): " "a = %d, b = %d\n", a, b); + foo (); + printf ("main(): " "a = %d, b = %d\n", a, b); + a = b = 12; + printf ("main(): " "a = %d, b = %d\n", a, b); + foo (); + + return 0; + + printf ("main(): " "a = %d, b = %d\n", a, b); +} diff --git a/20211011/functions-11.c b/20211011/functions-11.c new file mode 100644 index 0000000..ffffa79 --- /dev/null +++ b/20211011/functions-11.c @@ -0,0 +1,25 @@ +#include <stdio.h> + +int a = 0; +int b = 3; + +void foo (void) +{ + b++; + static int a = 5; + int b = 7; + printf ("foo(): " "a = %d, b = %d\n", a, b); + a++; +} + +int main (void) +{ + printf ("main(): " "a = %d, b = %d\n", a, b); + foo (); + printf ("main(): " "a = %d, b = %d\n", a, b); + a = b = 12; + printf ("main(): " "a = %d, b = %d\n", a, b); + foo (); + printf ("main(): " "a = %d, b = %d\n", a, b); + return 0; +} diff --git a/20211011/functions-2.c b/20211011/functions-2.c new file mode 100644 index 0000000..09d985f --- /dev/null +++ b/20211011/functions-2.c @@ -0,0 +1,12 @@ +#include <stdio.h> + +void add_verbose (int a, int b) +{ + printf ("%d + %d = %d\n", a, b, a + b); +} + +int main (void) +{ + add_verbose (3, 7); + return 0; +} diff --git a/20211011/functions-3.c b/20211011/functions-3.c new file mode 100644 index 0000000..5b4322f --- /dev/null +++ b/20211011/functions-3.c @@ -0,0 +1,13 @@ +#include <stdio.h> + +int add_verbose (int a, int b) +{ + printf ("%d + %d = %d\n", a, b, a + b); + return 42; +} + +int main (void) +{ + add_verbose (3, 7); + return 0; +} diff --git a/20211011/functions-4.c b/20211011/functions-4.c new file mode 100644 index 0000000..66eabf3 --- /dev/null +++ b/20211011/functions-4.c @@ -0,0 +1,14 @@ +#include <stdio.h> + +int add_verbose (int a, int b) +{ + printf ("%d + %d = %d\n", a, b, a + b); + return 42; +} + +int main (void) +{ + int a = add_verbose (3, 7); + printf ("Rückgabewert: %d\n", a); + return 0; +} diff --git a/20211011/functions-5.c b/20211011/functions-5.c new file mode 100644 index 0000000..b0a3a5f --- /dev/null +++ b/20211011/functions-5.c @@ -0,0 +1,14 @@ +#include <stdio.h> + +void add_verbose (int a, int b) +{ + printf ("%d + %d = %d\n", a, b, a + b); + return 42; +} + +int main (void) +{ + void a = add_verbose (3, 7); + printf ("Rückgabewert: %d\n", a); + return 0; +} diff --git a/20211011/functions-6.c b/20211011/functions-6.c new file mode 100644 index 0000000..354dd53 --- /dev/null +++ b/20211011/functions-6.c @@ -0,0 +1,26 @@ +#include <stdio.h> + +int a, b = 3; + +void foo (void) +{ + b++; + static int a = 5; + int b = 7; + printf ("foo(): " "a = %d, b = %d\n", a, b); + a++; +} + +int main (void) +{ + printf ("main(): " "a = %d, b = %d\n", a, b); + + return 0; + + foo (); + printf ("main(): " "a = %d, b = %d\n", a, b); + a = b = 12; + printf ("main(): " "a = %d, b = %d\n", a, b); + foo (); + printf ("main(): " "a = %d, b = %d\n", a, b); +} diff --git a/20211011/functions-7.c b/20211011/functions-7.c new file mode 100644 index 0000000..1d89a24 --- /dev/null +++ b/20211011/functions-7.c @@ -0,0 +1,27 @@ +#include <stdio.h> + +int a = 0; +int b = 3; + +void foo (void) +{ + b++; + static int a = 5; + int b = 7; + printf ("foo(): " "a = %d, b = %d\n", a, b); + a++; +} + +int main (void) +{ + printf ("main(): " "a = %d, b = %d\n", a, b); + foo (); + + return 0; + + printf ("main(): " "a = %d, b = %d\n", a, b); + a = b = 12; + printf ("main(): " "a = %d, b = %d\n", a, b); + foo (); + printf ("main(): " "a = %d, b = %d\n", a, b); +} diff --git a/20211011/functions-8.c b/20211011/functions-8.c new file mode 100644 index 0000000..2e18b51 --- /dev/null +++ b/20211011/functions-8.c @@ -0,0 +1,27 @@ +#include <stdio.h> + +int a = 0; +int b = 3; + +void foo (void) +{ + b++; + static int a = 5; + int b = 7; + printf ("foo(): " "a = %d, b = %d\n", a, b); + a++; +} + +int main (void) +{ + printf ("main(): " "a = %d, b = %d\n", a, b); + foo (); + printf ("main(): " "a = %d, b = %d\n", a, b); + + return 0; + + a = b = 12; + printf ("main(): " "a = %d, b = %d\n", a, b); + foo (); + printf ("main(): " "a = %d, b = %d\n", a, b); +} diff --git a/20211011/functions-9.c b/20211011/functions-9.c new file mode 100644 index 0000000..73a3ab6 --- /dev/null +++ b/20211011/functions-9.c @@ -0,0 +1,27 @@ +#include <stdio.h> + +int a = 0; +int b = 3; + +void foo (void) +{ + b++; + static int a = 5; + int b = 7; + printf ("foo(): " "a = %d, b = %d\n", a, b); + a++; +} + +int main (void) +{ + printf ("main(): " "a = %d, b = %d\n", a, b); + foo (); + printf ("main(): " "a = %d, b = %d\n", a, b); + a = b = 12; + printf ("main(): " "a = %d, b = %d\n", a, b); + + return 0; + + foo (); + printf ("main(): " "a = %d, b = %d\n", a, b); +} diff --git a/20211011/hp-20211011.pdf b/20211011/hp-20211011.pdf index ef596911793de3d62b3aaddab01464fb7517cf30..29fce7a42e97d44fe6867372ec13a2cbae8f3449 100644 GIT binary patch delta 2225 zcmZ3sRdCBz!G;#bElh08(>HQ6Y1f|(yX$}3K%oA8eBu&Ym8Korgr7HWU)$s-Y~W^n z(B->;YF?J6eC#Zy-|x%&?m9ZPMu}!td%XKo`27CgcaOLoC6zL46l^^mgC^`xXj8bJ zZc$>H#CUkh&lO@Bc0azIdNJSA$I?juoW&~REAw~VOncgXV$Y!f>C&{kd%}v&zc{~e zIi7d6czU_Sz~=e%UCc}}jIXC(XJ%5B+rQ_4+Xn7ghmu1MFgY-ZJUr2E!pzqsGyU;} z=Te8;r%SOg$=A!S=euI^rbI#R-NQ@Q_3X8~g?V3WT=n^jhh)C}kKA=;s}C0|tUfGR zT<EfO@yDy>b2|cOD+T7eRq9Q03sZ|XK6J9egvs%%%WRX)KM$te5&EhX=`peE(vv?{ z{j<~Zb_Z}}$#3ThocAr^eNf%u;#Yec)|-f*_)zd<=B3$!QaPn}>bv(`O-K~}@xf`D znd-G)Cm&P^vp)%GUE1~Hfr1S0(+?VUdee74{B7j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lsjzm>Sv}wa^cbUzZxRDqvNk< zoO^U~x769_nsxq*S-a=Q%si&qeZN*`(~sxVL-iv6d=H+u^y}UU3wFg`d)XJs<aJOj zfbEo{at6~bb6JM73s_%xEwWyn=e=uHX@lPd){@j$Y_<;Jy><(-k1|NGRE6DIwyTF% zmDzS--~#XUc{`I6WPBK64N9)sGA=vd>HXSQFEvy6=EeUX0t)!1cSo@(aGF|hsj9mA HyKw;k-OdUc diff --git a/20211011/hp-20211011.tex b/20211011/hp-20211011.tex index 76ff44e..535b15b 100644 --- a/20211011/hp-20211011.tex +++ b/20211011/hp-20211011.tex @@ -437,7 +437,8 @@ Apple Mac OS: \file{Xcode} \item Microsoft Windows: \file{Cygwin}\\ - oder \file{MinGW} mit \file{MSYS} + oder \file{MinGW} mit \file{MSYS}\\ + oder \file{WSL} mit \file{Xming} \medskip \item außerdem: Texteditor\\ diff --git a/20211011/pointers-1.c b/20211011/pointers-1.c new file mode 100644 index 0000000..421153a --- /dev/null +++ b/20211011/pointers-1.c @@ -0,0 +1,14 @@ +#include <stdio.h> + +void calc_answer (int a) +{ + a = 42; +} + +int main (void) +{ + int answer; + calc_answer (answer); + printf ("The answer is %d.\n", answer); + return 0; +} diff --git a/20211011/pointers-2.c b/20211011/pointers-2.c new file mode 100644 index 0000000..3bd2e86 --- /dev/null +++ b/20211011/pointers-2.c @@ -0,0 +1,14 @@ +#include <stdio.h> + +void calc_answer (int *a) +{ + *a = 42; +} + +int main (void) +{ + int answer; + calc_answer (&answer); + printf ("The answer is %d.\n", answer); + return 0; +} diff --git a/20211011/pointers-3-O0.s b/20211011/pointers-3-O0.s new file mode 100644 index 0000000..6a28ff5 --- /dev/null +++ b/20211011/pointers-3-O0.s @@ -0,0 +1,55 @@ + .file "pointers-3.c" + .text + .globl calc_answer + .type calc_answer, @function +calc_answer: +.LFB0: + .cfi_startproc + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset 6, -16 + movq %rsp, %rbp + .cfi_def_cfa_register 6 + movq %rdi, -8(%rbp) + movq -8(%rbp), %rax + movl $42, (%rax) + nop + popq %rbp + .cfi_def_cfa 7, 8 + ret + .cfi_endproc +.LFE0: + .size calc_answer, .-calc_answer + .section .rodata +.LC0: + .string "The answer is %d.\n" + .text + .globl main + .type main, @function +main: +.LFB1: + .cfi_startproc + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset 6, -16 + movq %rsp, %rbp + .cfi_def_cfa_register 6 + subq $16, %rsp + movl -4(%rbp), %eax + cltq + movq %rax, %rdi + call calc_answer + movl -4(%rbp), %eax + movl %eax, %esi + leaq .LC0(%rip), %rdi + movl $0, %eax + call printf@PLT + movl $0, %eax + leave + .cfi_def_cfa 7, 8 + ret + .cfi_endproc +.LFE1: + .size main, .-main + .ident "GCC: (Debian 8.3.0-6) 8.3.0" + .section .note.GNU-stack,"",@progbits diff --git a/20211011/pointers-3-O1.s b/20211011/pointers-3-O1.s new file mode 100644 index 0000000..c03481f --- /dev/null +++ b/20211011/pointers-3-O1.s @@ -0,0 +1,36 @@ + .file "pointers-3.c" + .text + .globl calc_answer + .type calc_answer, @function +calc_answer: +.LFB11: + .cfi_startproc + movl $42, (%rdi) + ret + .cfi_endproc +.LFE11: + .size calc_answer, .-calc_answer + .section .rodata.str1.1,"aMS",@progbits,1 +.LC0: + .string "The answer is %d.\n" + .text + .globl main + .type main, @function +main: +.LFB12: + .cfi_startproc + subq $8, %rsp + .cfi_def_cfa_offset 16 + movl $0, %esi + leaq .LC0(%rip), %rdi + movl $0, %eax + call printf@PLT + movl $0, %eax + addq $8, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_endproc +.LFE12: + .size main, .-main + .ident "GCC: (Debian 8.3.0-6) 8.3.0" + .section .note.GNU-stack,"",@progbits diff --git a/20211011/pointers-3.c b/20211011/pointers-3.c new file mode 100644 index 0000000..7867933 --- /dev/null +++ b/20211011/pointers-3.c @@ -0,0 +1,14 @@ +#include <stdio.h> + +void calc_answer (int *a) +{ + *a = 42; +} + +int main (void) +{ + int answer; + calc_answer (answer); + printf ("The answer is %d.\n", answer); + return 0; +} diff --git a/20211011/side-effects-1.c b/20211011/side-effects-1.c new file mode 100644 index 0000000..61c4abb --- /dev/null +++ b/20211011/side-effects-1.c @@ -0,0 +1,8 @@ +#include <stdio.h> + +int main (void) +{ + printf ("Hello, world!\n"); + "Hello, world!\n"; + return 0; +} diff --git a/20211011/side-effects-10.c b/20211011/side-effects-10.c new file mode 100644 index 0000000..a8b7d83 --- /dev/null +++ b/20211011/side-effects-10.c @@ -0,0 +1,8 @@ +#include <stdio.h> + +int main (void) +{ + double pi = 3.14159; + printf ("pi = %lf\n", pi); + return 0; +} diff --git a/20211011/side-effects-11.c b/20211011/side-effects-11.c new file mode 100644 index 0000000..ec7fb45 --- /dev/null +++ b/20211011/side-effects-11.c @@ -0,0 +1,8 @@ +#include <stdio.h> + +int main (void) +{ + double pi = 3, po = 14159; + printf ("pi = %lf, po = %lf\n", pi, po); + return 0; +} diff --git a/20211011/side-effects-12.c b/20211011/side-effects-12.c new file mode 100644 index 0000000..9ebbaa2 --- /dev/null +++ b/20211011/side-effects-12.c @@ -0,0 +1,8 @@ +#include <stdio.h> + +int main (void) +{ + double pi = (3,14159); + printf ("pi = %lf\n", pi); + return 0; +} diff --git a/20211011/side-effects-13.c b/20211011/side-effects-13.c new file mode 100644 index 0000000..b6d4b13 --- /dev/null +++ b/20211011/side-effects-13.c @@ -0,0 +1,15 @@ +#include <stdio.h> + +int main (void) +{ + double pi = 3.14159265358979323846; + printf ("pi = %lf\n", pi); + printf ("Vielfache von pi:\n"); + double x = pi; + for (int i = 1; i <= 10; i++) + { + printf ("%2d: %lf\n", x); + x += pi; + } + return 0; +} diff --git a/20211011/side-effects-14.c b/20211011/side-effects-14.c new file mode 100644 index 0000000..6b14797 --- /dev/null +++ b/20211011/side-effects-14.c @@ -0,0 +1,15 @@ +#include <stdio.h> + +int main (void) +{ + double pi = 3.14159265358979323846; + printf ("pi = %lf\n", pi); + printf ("Vielfache von pi:\n"); + double x = pi; + for (int i = 1; i <= 10; i++) + { + printf ("%2d: %lf\n", i, x); + x += pi; + } + return 0; +} diff --git a/20211011/side-effects-15.c b/20211011/side-effects-15.c new file mode 100644 index 0000000..ea4a227 --- /dev/null +++ b/20211011/side-effects-15.c @@ -0,0 +1,12 @@ +#include <stdio.h> + +int main (void) +{ + double pi = 3.14159265358979323846; + printf ("pi = %lf\n", pi); + printf ("Vielfache von pi:\n"); + double x; + for (int i = 1, x = pi; i <= 10; i++, x += pi) + printf ("%2d: %lf\n", i, x); + return 0; +} diff --git a/20211011/side-effects-16.c b/20211011/side-effects-16.c new file mode 100644 index 0000000..86570b8 --- /dev/null +++ b/20211011/side-effects-16.c @@ -0,0 +1,13 @@ +#include <stdio.h> + +int main (void) +{ + double pi = 3.14159265358979323846; + printf ("pi = %lf\n", pi); + printf ("Vielfache von pi:\n"); + int i; + double x; + for (i = 1, x = pi; i <= 10; i++, x += pi) + printf ("%2d: %lf\n", i, x); + return 0; +} diff --git a/20211011/side-effects-17.c b/20211011/side-effects-17.c new file mode 100644 index 0000000..ab2fae4 --- /dev/null +++ b/20211011/side-effects-17.c @@ -0,0 +1,13 @@ +#include <stdio.h> + +int main (void) +{ + double pi = 3.14159265358979323846; + printf ("pi = %lf\n", pi); + printf ("Vielfache von pi:\n"); + int i = 1; + double x = pi; + for (; i <= 10; i++, x += pi) + printf ("%2d: %lf\n", i, x); + return 0; +} diff --git a/20211011/side-effects-18.c b/20211011/side-effects-18.c new file mode 100644 index 0000000..62c8cd1 --- /dev/null +++ b/20211011/side-effects-18.c @@ -0,0 +1,13 @@ +#include <stdio.h> + +int main (void) +{ + double pi = 3.14159265358979323846; + printf ("pi = %lf\n", pi); + printf ("Vielfache von pi:\n"); + int i = 1; + double x = pi; + for (; i <= 10; x += pi) + printf ("%4d: %lf\n", i++, x); + return 0; +} diff --git a/20211011/side-effects-19.c b/20211011/side-effects-19.c new file mode 100644 index 0000000..d2a8706 --- /dev/null +++ b/20211011/side-effects-19.c @@ -0,0 +1,13 @@ +#include <stdio.h> + +int main (void) +{ + double pi = 3.14159265358979323846; + printf ("pi = %lf\n", pi); + printf ("Vielfache von pi:\n"); + int i = 1; + double x = 0.0; + for (; i <= 10;) + printf ("%4d: %lf\n", i++, x += pi); + return 0; +} diff --git a/20211011/side-effects-2.c b/20211011/side-effects-2.c new file mode 100644 index 0000000..275a28e --- /dev/null +++ b/20211011/side-effects-2.c @@ -0,0 +1,8 @@ +#include <stdio.h> + +int main (void) +{ + printf ("Hello, world!\n"); + 42; + return 0; +} diff --git a/20211011/side-effects-20.c b/20211011/side-effects-20.c new file mode 100644 index 0000000..7b1ff96 --- /dev/null +++ b/20211011/side-effects-20.c @@ -0,0 +1,13 @@ +#include <stdio.h> + +int main (void) +{ + double pi = 3.14159265358979323846; + printf ("pi = %lf\n", pi); + printf ("Vielfache von pi:\n"); + int i = 1; + double x = 0.0; + while (i <= 10) + printf ("%4d: %lf\n", i++, x += pi); + return 0; +} diff --git a/20211011/side-effects-3.c b/20211011/side-effects-3.c new file mode 100644 index 0000000..38c183e --- /dev/null +++ b/20211011/side-effects-3.c @@ -0,0 +1,8 @@ +#include <stdio.h> + +int main (void) +{ + printf ("Hello, world!\n"); + int a = 42; + return 0; +} diff --git a/20211011/side-effects-4.c b/20211011/side-effects-4.c new file mode 100644 index 0000000..e316c74 --- /dev/null +++ b/20211011/side-effects-4.c @@ -0,0 +1,8 @@ +#include <stdio.h> + +int main (void) +{ + int a = printf ("Hello, world!\n"); + printf ("Die Antwort lautet: %d\n", a); + return 0; +} diff --git a/20211011/side-effects-5.c b/20211011/side-effects-5.c new file mode 100644 index 0000000..aef0a3d --- /dev/null +++ b/20211011/side-effects-5.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +int main (void) +{ + int a = 137; + int b = a = 42; + printf ("Die Antwort lautet: %d\n", a); + printf ("Die Bntwort lautet: %d\n", b); + return 0; +} diff --git a/20211011/side-effects-6.c b/20211011/side-effects-6.c new file mode 100644 index 0000000..be6f48e --- /dev/null +++ b/20211011/side-effects-6.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +int main (void) +{ + int a = 137; + int b = a += 42; + printf ("Die Antwort lautet: %d\n", a); + printf ("Die Bntwort lautet: %d\n", b); + return 0; +} diff --git a/20211011/side-effects-7.c b/20211011/side-effects-7.c new file mode 100644 index 0000000..bd9fe63 --- /dev/null +++ b/20211011/side-effects-7.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +int main (void) +{ + int a = 137; + int b = a++; + printf ("Die Antwort lautet: %d\n", a); + printf ("Die Bntwort lautet: %d\n", b); + return 0; +} diff --git a/20211011/side-effects-8.c b/20211011/side-effects-8.c new file mode 100644 index 0000000..b364305 --- /dev/null +++ b/20211011/side-effects-8.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +int main (void) +{ + int a = 137; + int b = ++a; + printf ("Die Antwort lautet: %d\n", a); + printf ("Die Bntwort lautet: %d\n", b); + return 0; +} diff --git a/20211011/side-effects-9.c b/20211011/side-effects-9.c new file mode 100644 index 0000000..effe4f6 --- /dev/null +++ b/20211011/side-effects-9.c @@ -0,0 +1,8 @@ +#include <stdio.h> + +int main (void) +{ + double pi = 3,14159; + printf ("pi = %lf\n", pi); + return 0; +} -- GitLab