From bf5b6647b9a1325809ce572f80a4424c940c9ab1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mert=20G=C3=B6r?= Date: Wed, 30 Oct 2024 08:10:50 +0300 Subject: [PATCH] local variable and global variable --- ChangeLog | 2 ++ c-basic/local_vs_global.c | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 c-basic/local_vs_global.c diff --git a/ChangeLog b/ChangeLog index 3de6687..b243405 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2024-10-30 Mert Gör + * c-basic/local_vs_global.c (main): local variable and global variable + * c-basic/C.pdf: page 24 scope * c-basic/void.c (main): Void/Return diff --git a/c-basic/local_vs_global.c b/c-basic/local_vs_global.c new file mode 100644 index 0000000..16d21eb --- /dev/null +++ b/c-basic/local_vs_global.c @@ -0,0 +1,19 @@ +#include + +int main() +{ + int a; + + { + int b; + + b = 20; + a = 10; + + printf("a = %d, b = %d\n", a, b); + + } + + printf("a = %d\n", a); // correct + // printf("b = %d\n", b); // incorrect/error +}