Find the total marks obtained according to given marking scheme | Function that calculates marks . ; for not attempt score + 0 ; for each correct answer score + 3 ; for each wrong answer score - 1 ; calculate total marks ; Driver code
< ? php function markingScheme ( $ N , $ answerKey , $ studentAnswer ) { $ positive = 0 ; $ negative = 0 ; $ notattempt = 0 ; for ( $ i = 0 ; $ i < $ N ; $ i ++ ) { if ( $ studentAnswer [ $ i ] == 0 ) $ notattempt ++ ; else if ( $ answerKey [ $ i ] == $ studentAnswer [ $ i ] ) $ positive ++ ; else if ( $ answerKey [ $ i ] != $ studentAnswer [ $ i ] ) $ negative ++ ; } return ( $ positive * 3 ) + ( $ negative * -1 ) ; } $ answerKey = array ( 1 , 2 , 3 , 4 , 1 ) ; $ studentAnswer = array ( 1 , 2 , 3 , 4 , 0 ) ; $ N = sizeof ( $ answerKey ) ; echo markingScheme ( $ N , $ answerKey , $ studentAnswer ) ; ? >