In this case heat is given by water and taken by ice.
Heat available with water to cool from `30^(@)`C to `0^(@)`C
`=mcDeltaT=5xx1xx30`=150cal ltbrlt Heat required by 5g ice to increase its temperature up to `0^(@)`C
`mcDeltaT` = `5xx0.5xx20`=50cal
Out of 150 cal heat available, 50cal is used for increasing tempeature of ice from `-20^(@)`C to `0^(@)`C. The remaining heat 100 cal is used for melting the ice.
If mass of ice melted is mg then
`mxx80 =100 rArr` m=1.25g
Thus, 1.25g ice out of 5g melts and mixture of ice and water is at `0^(@)`C.