0% found this document useful (0 votes)
15 views5 pages

LOOP

The document describes a loop program that initializes and executes a series of increments based on a specified condition. It illustrates the RAM diagram representation before and after data declaration, initialization, and inputting. The program executes a loop that adds values to a variable 'n' from 1 to 5, showing the changes in memory at each step.

Uploaded by

mahengejimson02
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views5 pages

LOOP

The document describes a loop program that initializes and executes a series of increments based on a specified condition. It illustrates the RAM diagram representation before and after data declaration, initialization, and inputting. The program executes a loop that adds values to a variable 'n' from 1 to 5, showing the changes in memory at each step.

Uploaded by

mahengejimson02
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

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

You might also like