C Program to Demonstrate global and internal variables.

C Program to Demonstrate global and internal variables.When variable declared outside the all the blocks, they are called global variables, and they are initialized by the system. Variables declared within the functions are called as internal variables, the are locale to that function, and user only initialize the variable. Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/


#include<stdio.h>

int counter = 0; /* global because we are outside
all blocks. */
int func(void);

main()
{
counter++; /* global because it has not been
declared within this block */
printf("counter is %2d before the call to funcn", counter);

func(); /* call a function. */

printf("counter is %2d after the call to funcn", counter);
}

int func(void)
{
int counter = 10; /* local. */
printf("counter is %2d within funcn", counter);
}
Read more Similar C Programs
Learn C Programming

Number System

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

Leave a Reply