in the video at “7:40” when we used cin but still haven’t declared p,r,t as float it is giving the output as float.
So how the typecasting is not having effect on the answer
Simple interest program
@Abhinav_Jha
Although the three variables p,r,t are declared as variable , the answer will still be float because the calculation is performed as
si = prt / 100.0 ;
Since p,r,t are int , their product (prt) is calculated as int only but when it is divided by a float value - 100.0 , the resultant value = prt/100.0 would be a float value. Since ‘si’ is a float variable , we are able to store this float value in it and then print it.
1 Like
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.