example for register storage class - computer


Example for Register Storage Class - computer programming?

main()
{
register int i;
for (i=0; i< LIMIT; ++i)
{
...............
...............
}
} /* block exit will free the register.*/

Although we have declared the storage class ‘i' as register we can't say for sure that the value of i would be stored in a CPU register because the number of CPU registers are limited. And they perhaps busy doing some other work. In such situations the variable works as if its storage class in 'auto'. For all time remember that a register declaration is taken only as advice to the compiler.

We can't use register storage class for all kinds of variables. The subsequent declarations are not correct.

register float q;
register double a;
register long c; 

This is for the reason that the CPU registers in a microcomputer are typically 16 bit registers and therefore cannot hold a float or double value which requires 4 and 8 values respectively. It would not give any error message, other than works as auto storage class.

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: example for register storage class - computer
Reference No:- TGS0305043

Expected delivery within 24 Hours