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

Write a program that illustrate creation of a data file, Write a Program th...

Write a Program that illustrate creation of a data file? Here is a program to generate a Fibonacci series and write it into a Data file. # include main() { FILE *fpt;

Assigment, Hi is there any chance to get assignment for fresher tutor

Hi is there any chance to get assignment for fresher tutor

Explain reusability, Reusability  Reusability means reusing code writte...

Reusability  Reusability means reusing code written earlier, may be from some earlier project or from the library. Reusing old code not only saves development time, but also sa

Area under curve, write a program to find the area under curve y=f(x) betwe...

write a program to find the area under curve y=f(x) between x=a and x=b,integrate y=f(x) between the limits a and b

Storing street addresses with doubly linked lists, Write a C++ program with...

Write a C++ program with header and source files to store street addresses using the Doubly Linked List ADT. Modify the Node class from Lab Assignment 3 so that it becomes a node i

Program to creates a linked list of characters , Note: Please refer to the...

Note: Please refer to the Subject Outline for details regarding the assessment of the advanced assignment. The Problem You are to investigate the use of data structures an

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;

Advanced features of c, We are now quite happy to use the basic mathematica...

We are now quite happy to use the basic mathematical expressions, however in engineering we use scientific functions i.e Sin , Cos  , ln etc . Within C we have the following functi

Virtual constructor, Is it possible to have Virtual Constructor? If yes, ho...

Is it possible to have Virtual Constructor? If yes, how? If not, Why not possible?

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