Q14 A machine is purchased which will produce earning of Rs. 1000 per year while it lasts. The machine costs Rs. 6000 and will have a salvage value of Rs. 2000 when it condemned. If 9 percent per annum can be earned on alternate investments, write a program to determine what will be the minimum life of the machine to make it a more attractive investment compared to alternative investment?
Program: 107
A machine is purchased which will produce earning of Rs. 1000 per year while it lasts. The machine costs Rs. 6000 and will have a salvage value of Rs. 2000 when it condemned. If 9 percent per annum can be earned on alternate investments, write a c program to determine what will be the minimum life of the machine to make it a more attractive investment compared to alternative investment?
Output:
The Life of Machine: 5 years
this code doesn’t work bro.
The reason the code doesn’t always work is because the alternate and invest variables are set randomly, so the loop won’t always start unless you set alternate as greater than invest before the loop.
wrong code : initiation of loop is invalid
We should use do-while loop here.