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

Inbuilt functions in cpp, Inbuilt Functions i).  Functions to manipulate...

Inbuilt Functions i).  Functions to manipulate strings The cstring library defines many functions to perform some manipulation operations with C-styled functions. The followi

How does c++ help with the tradeoff of security vs.usability, A: In C, enca...

A: In C, encapsulation was completed by making things static in a compilation unit or module. It prevented another module from accessing the static stuff. (Incidentally, now static

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

Write a program 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 b

Intro to C++ Lab Help, I have a very confusing assignment and I''m struggli...

I have a very confusing assignment and I''m struggling to find the right place to begin or how to break the problem down.

Program, program to check whether a given point lies inside a rectangle or ...

program to check whether a given point lies inside a rectangle or not

Introduction of computer and programming concept, Classify computer system ...

Classify computer system according to capacity. How they are different from computers according to the classification of technology. Provide comparative study also.

Usb photobackup, Project Description: Prepare software that will work with ...

Project Description: Prepare software that will work with our USB hardware that easily lets you backup all the pictures in your computer into the USB stick in one single step. Once

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