local variable and global variable
This commit is contained in:
parent
a7e3c96ae2
commit
bf5b6647b9
@ -1,5 +1,7 @@
|
||||
2024-10-30 Mert Gör <mertgor@masscollabs.xyz>
|
||||
|
||||
* 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
|
||||
|
19
c-basic/local_vs_global.c
Normal file
19
c-basic/local_vs_global.c
Normal file
@ -0,0 +1,19 @@
|
||||
#include <stdio.h>
|
||||
|
||||
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
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user