UNIVERSITY OF DODOMA
COLLEGE OF INFORMATIC AND VIRTUAL EDUCATION (CIVE)
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING (CSE)
Student Name: JIDEN EMANUEL MICHAEL
Registration Number: AT22-03-035767
Program: BSc SE
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
n
RESERVED
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
n
0
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
n
1
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
The selection program.
The selection program source code
The output of the selection program
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 x
FREE
FREE
FREE
FREE
RESERVED X
y
RESERVED
FREE
FREE
FREE
FREE
RESERVED
X
Y RESERVED
Z RESERVED
FREE
FREE
(iii) Data inputting, the reserved memory allocations in a RAM are then feeded by the respective
data as an input
4 X
RESERVED y
z
RESERVED
FREE
FREE
4 X
2 Y
RESERVED z
FREE
FREE
(iv) Data execution. After the data feeding the program tends to select one instruction that fits
the conditions of the program.
Case01: if the inputted value of x is greater than that of y (x>y) then the program will select
for x/y.
Case02: if the inputted value of x is less than that of y (x<y) then the program will select for
y/x.
Since my data was x greater than y then the selected instruction was that of x/y
4 X
2 Y
2 z
FREE
FREE