Answer:
Yes, it will be after 6 hours: 50 mg, after 12 hours: 25 mg, and after 18 hours: 12.5 mg
Explanation:
Remember coral is a functional programming language and follows Pythons functional programming paradigm. Remember Python supports functional, imperative as well as OOPS paradigm.
The function will be:
def void calcamtleft(int amt):
integer a=6
integer time=6
integer i=1
while amt> 0:
amt=amt/2
print("After"+time+" hours:" +amt+"mg")
i++
time=a* i
Hence in first loop amt=100
new amt=100/2=50
After 6 hours: 50 mg ( this will be printed)
i will increment then, and time will be = 6 *2 =12
now input amt=50
new amt=50/2=25
After 12 hours 25 mg (this will be output)
i will increment then, and time will be = 6 *3 =18
now input amt=25
new amt=25/2=12.5
After 18 hours 12.5 mg (this will be output)
i will increment then, and time will be = 6 *4 =24
now input amt=12.5/2= 6.25
new amt=6.25/2= 3.125
After 24 hours 3.125 mg (this will be output)
i will increment then, and time will be = 6 *5 =30
now input amt=3.125
new amt=3.125/2= 1.5625
After 30 hours 1.5625 mg
And this will continue till amt>0