Please convert the following designs into C++ Program
One program per design. Design's are practically the same thing.
-----What's Needed:-----
The Program and the appended output for each design.
Append the output to the source program.
Verify that the output for each program agrees with the trace table
for it's exercise.
---Design---
Design 12.3
/* Data Declarations */
a: INTEGER
b: INTEGER
f: INTEGER
/* Initializations */
a = 10
b = 15
f = 6
WHILE (f < a) DO
b = b + 3
f = f + 1
PRINT 'f = ', f, 'a = ',a
ENDWHILE
STOP 12.3
-----------
Design 12.4
/* Data Declarations */
a: INTEGER
b: INTEGER
f: INTEGER
/* Initializations */
a = 10
b = 15
f = 6
WHILE (f < a) DO
PRINT 'f = ', f, 'a = ',a
b = b + 3
f = f + 1
ENDWHILE
STOP 12.4
----------
Design 12.5
/* Data Declarations */
a: INTEGER
b: INTEGER
f: INTEGER
/* Initializations */
a = 10
b = 15
f = 6
WHILE (f < a) DO
b = b + 3
f = f + 1
ENDWHILE
PRINT 'f = ', f, 'a = ',a
STOP 12.5
----------
Design 12.6
/* Data Declarations */
a: INTEGER
b: INTEGER
f: INTEGER
/* Initializations */
a = 10
b = 15
f = 6
WHILE (f <= 12) DO
IF (a >=6) THEN
b = b - 2
a = a - 3
ENDIF
f = f + 1
ENDWHILE
PRINT 'a = ', a
PRINT 'b = ', b
PRINT 'f = ', f
STOP 12.6
-----------
Design 12.7
/* Data Declarations */
a: INTEGER
b: INTEGER
f: INTEGER
/* Initializations */
a = 10
b = 15
f = 6
WHILE (f <= 12) DO
IF (a >=6) THEN
b = b - 2
a = a - 3
ELSE
b = b + 5
ENDIF
f = f + 1
ENDWHILE
PRINT 'a = ', a
PRINT 'b = ', b
PRINT 'f = ', f
STOP 12.7
----------
Design 12.8
/* Data Declarations */
a: INTEGER
b: INTEGER
f: INTEGER
/* Initializations */
a = 10
b = 15
f = 6
WHILE (f <= 12) DO
IF (a >=6) THEN
b = b - 2
a = a - 3
ELSE
b = b + 5
f = f + 1
ENDIF
f = f + 1
ENDWHILE
IF (b >= 20) THEN
PRINT 'b >= 20'
ELSE
PRINT 'a = ', a
PRINT 'b = ', b
PRINT 'f = ', f
ENDIF
PRINT 'Hello'
STOP 12.8
----------- |