Program to find the profit or loss when CP of N items is equal to SP of M items | Function to calculate Profit or loss ; Driver Code
< ? php function profitLoss ( $ N , $ M ) { if ( $ N == $ M ) echo " No ▁ Profit ▁ nor ▁ Loss " ; else { $ result = 0.0 ; $ result = ( abs ( $ N - $ M ) ) / $ M ; if ( $ N - $ M < 0 ) echo " Loss ▁ = ▁ - " , $ result * 100 , " % " ; else echo " Profit ▁ = ▁ " , $ result * 100 , " % " ; } } $ N = 8 ; $ M = 9 ; profitLoss ( $ N , $ M ) ; ? >