local variable and global variable

This commit is contained in:
Mert Gör
2024-10-30 08:10:50 +03:00
parent a7e3c96ae2
commit bf5b6647b9
2 changed files with 21 additions and 0 deletions

19
c-basic/local_vs_global.c Normal file
View 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
}