Full Question
1. Correct the following code and
2. Convert the do while loop the following code to a while loop
declare integer product
declare integer number
product = 0
do while product < 100
display ""Type your number""
input number
product = number * 10
loop
display product
End While
Answer:
1. Code Correction
The errors in the code segment are:
a. The use of do while on line 4
You either use do or while product < 100
b. The use of double "" as open and end quotes for the string literal on line 5
c. The use of "loop" statement on line 7
The correction of the code segment is as follows:
declare integer product
declare integer number
product = 0
while product < 100
display "Type your number"
input number
product = number * 10
display product
End While
2. The same code segment using a do-while statement
declare integer product
declare integer number
product = 0
Do
display "Type your number"
input number
product = number * 10
display product
while product < 100
Answer:
total amount of water after 2 min will be 84.4 kg/s
Explanation:
Given data:
one tank inflow = 0.1 kg/s
2nd tank inflow = 0.3 kg/s
3rd tank outflow = 0.03 kg/s
Total net inflow in tank is = 0.3 +0.1 =0.4 kg/s
From third point, outflow is 0.03 kg/s
Therefore, resultant in- flow = 0.4 - 0.03
Resultant inflow is = 0.37 kg/s
Tank has initially 40 kg water
In 2 min ( 2*60 sec), total inflow in tank is 0.37*60*2 = 44.4 kg
So, total amount of water after 2 min will be = 40+44.4 = 84.4 kg