define scope rules of c program - computer


Define Scope Rules of C program - Computer Programming?

The fundamental rule of scope is that identifiers are accessible only within the block in which they are declared and they are unknown outside the boundaries of that block.

The scope of the variable determines over what part of the program and a variable is actually available for use.

Let us see a simple instance

main()
{
int a=2; /*outer .block a*/

printf("%d\n",a); /* 2 is printed*/

{
int a=5; /*inner block a*/

printf("%d\n",a); /* 5 is printed*/

} /*back to the outer block*/

printf("%d\n",a); /* 2 is printed*/
}

Every block introduces its own nomenclature. A name of outer block is valid until an inner block redefines it. If redefined the outer block name is masked or hidden from the inner block.

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: define scope rules of c program - computer
Reference No:- TGS0305020

Expected delivery within 24 Hours