From b39bf20053c3903ad8b1b1211ce9ef03d7e7bfa2 Mon Sep 17 00:00:00 2001 From: adithyaanilkumar Date: Mon, 29 Jun 2020 09:42:16 +0530 Subject: [PATCH] added array to glob var --- C/global_var.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 C/global_var.c diff --git a/C/global_var.c b/C/global_var.c new file mode 100644 index 0000000..31fc71e --- /dev/null +++ b/C/global_var.c @@ -0,0 +1,32 @@ +//global variable example + +#include + +int fun1(void); +int fun2(void); +int fun3(void); + +int x ; /* global */ + +void main( ) +{ + x = 10 ; /* global x */ + printf("x = %d\n", x); + printf("x = %d\n", fun1()); + printf("x = %d\n", fun2()); + printf("x = %d\n", fun3()); +} +fun1(void) +{ + x = x + 10 ; +} +int fun2(void) +{ + int x ; /* local */ + x = 1 ; + return (x); +} +fun3(void) +{ + x = x + 10 ; /* global x */ +} \ No newline at end of file