explain register variablecomputers have internal


Explain Register Variable

Computers have internal registers, which are used to keep data temporarily, before any operation can be performed. Intermediate results of the calculations are also stored in registers. Operations can be performed on the data stored in registers more quickly than on the data stored in memory. This is because the registers are a part of the processor itself. If a certain variable is used often - for instance, the control variable in a loop can be assigned a register, rather than a variable. This is done using the keyword register. Though, a register is assigned by the compiler only if it is free, otherwise it is taken as automatic. Also, global variables cannot be register variables.

e.g.

                void loopfn()

                 {

                  register int i;

                                for(i=0; i< 100; i++)

                                 {

                                                cout << i;

                                 }

                 }

 

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: explain register variablecomputers have internal
Reference No:- TGS0309233

Expected delivery within 24 Hours