Concentration of juice after mixing n glasses in equal proportion | Function to return the concentration of the resultant mixture ; Driver code
< ? php function mixtureConcentration ( $ n , $ p ) { $ res = 0 ; for ( $ i = 0 ; $ i < $ n ; $ i ++ ) $ res += $ p [ $ i ] ; $ res /= $ n ; return $ res ; } $ arr = array ( 0 , 20 , 20 ) ; $ n = count ( $ arr ) ; print ( round ( mixtureConcentration ( $ n , $ arr ) , 4 ) ) ; ? >