Define scope rules of c program - computer programming, C/C++ Programming

Assignment Help:

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.


Related Discussions:- Define scope rules of c program - computer programming

Program of conversion from basic to user-defined variable, Conversion from ...

Conversion from Basic to User-Defined variable Consider the following example. class Distance                  {                   public  :

How many ways are there to initialize an int with a constant, There are two...

There are two ways for initializes in C++ as shown in the example that follows. The first way uses the traditional C notation. The second way uses constructor notation. int foo

Linking source code in vc++ 6.0, i have a project in BDD(Binary Decision Di...

i have a project in BDD(Binary Decision Diagram).. where i have to use BDD library...i m using cudd package which uses BDD technique...i download cudd package..try to run in vc++ 6

Define reference?, A: This is a name that acts as an alias, or alternative ...

A: This is a name that acts as an alias, or alternative name, for a beforehand defined variable or an object. prepending variable along with "&" symbol makes it as reference. fo

Assesors, what are assessor. elaborate with clear easy diagrams

what are assessor. elaborate with clear easy diagrams

Data structure and algorithm, implement two stacks in one array A[1...n] in...

implement two stacks in one array A[1...n] in such a way that neither stack overflows unless the total number of elements in both stacks together is n. For this you need to produce

Explain protected and public in c++, Explain protected, public, private in ...

Explain protected, public, private in C++? These are three access spaecifiers in C++. - Public - Here data members and functions are accessible outside the class. - Pr

Write a program in c++ to read n numbers in an array, Problem Write a p...

Problem Write a program in C++ to read N numbers in an array, the user should be able to search a particular number in the array using sequential search algorithm. Writing a

C program for total & average in the array , C Program for TOTAL  & AVERA...

C Program for TOTAL  & AVERAGE IN THE ARRAY  #include stdio.h> #include conio.h> #include string.h> void main() {           int i=0,n[100],limit=0,a=0;

Mathematics, C Coding to find the area under the curve y = f(x) between x =...

C Coding to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can be found

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd