The code of loop program
The output of loop program is:
RAM DIAGRAM REPRESENTATION OF THE PROGRAM ABOVE
(i) Before data declaration, the RAM seen as seen below
FREE
FREE
FREE
FREE
FREE
(ii) Data initialization, during data initialization some memory space in a RAM are being
reserved.
RESERVED i
FREE
FREE
FREE
FREE
RESERVED i
RESERVED n
FREE
FREE
FREE
(iii) Data inputting, the reserved memory allocations in a RAM are then feeded by the respective
data as an input
1 i
0 n
FREE
FREE
FREE
(iv) The data execution will be done in repletion till the condition (loop) meets the end of the
condition. This is as seen in steps below
Step01:
First increment for the condition for (i=1; i<6; ++i) {
n = n +I;
2
i
1 n
FREE
FREE
FREE
Step02:
Second increment for the condition for (i=1; i<6; ++i) {
n = n +I;
}
3 i
3 n
FREE
FREE
FREE
Step03:
The third increment for the condition for (i=1; i<6; ++i) {
n = n +I;
4 i
6 n
FREE
FREE
Step04:
The fourth increment for the condition for (i=1; i<6; ++i) {
n = n +I;
6 i
10 n
FREE
FREE
Step05:
The fifth and last increment for the condition for (i=1; i<6; ++i) {
n = n +I;
6 i
15 n
FREE
FREE