Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

what is the difference between static variable and register
variable?

Answer Posted / naresh lingampally

Variables defined local to a function disappear at the end
of the function scope. So when we call the function again,
storage for variables is created and
values are reinitialized.

Static variables:
So if we want the value to be extent throughout the life of
a program, we can define the local variable as "static."
Initialization is performed only at the first call and data
is retained between func calls.

REGISTER VARIABLE :

Register variables are a special case of automatic
variables. Automatic variables are allocated storage in the
memory of the computer; however, for most computers,
accessing data in memory is considerably slower than
processing in the CPU. These computers often have small
amounts of storage within the CPU itself where data can be
stored and accessed quickly. These storage cells are called
registers.

Normally, the compiler determines what data is to be stored
in the registers of the CPU at what times. However, the C
language provides the storage class register so that the
programmer can ``suggest'' to the compiler that particular
automatic variables should be allocated to CPU registers, if
possible. Thus, register variables provide a certain control
over efficiency of program execution. Variables which are
used repeatedly or whose access times are critical, may be
declared to be of storage class register.

Also these register variables are used in huge projects the
tiny program developers are not interested to include these
register variables, because the tiny programs never requires
more time complete its job. These register variables may be
used to store constant values so as to make use of it
anywhere in the programs.

main{ register float a=0;}

Is This Answer Correct ?    19 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain how do you list files in a directory?

1019


Is malloc memset faster than calloc?

1018


What do you know about the use of bit field?

990


Are the outer parentheses in return statements really optional?

1054


What is queue in c?

1038


Why we use conio h in c?

1158


How can you restore a redirected standard stream?

1060


using only #include and #include Write a program in C that will read an input from the user and print it back to the user if it is a palindrome. The string ends when it encounters a whitespace. The input string is at most 30 characters. Assume the string has no spaces and distinguish between and lowercase. So madam is a palindrome, but MadAm is not a palindrome. Use scanf and %s to read the string. Sample Test: Enter a string: madam madam is a palindrome. Enter a string: 09023 09023 is not a palindrome.

1770


What is extern storage class in c?

946


C program execution always begins with a) #include b) comment (/*-------*/) c) main() d) declaration instructions

1004


How many types of operators are there in c?

986


Are pointers really faster than arrays?

969


How the c program is executed?

1080


Write a C program to count the number of email on text

1857


Describe the complexity of Binary search, Quicksort and various other sorting and searching techniques..

990