Find the total marks obtained according to given marking scheme | C # implementation of above approach ; 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
using System ; class GFG { static int markingScheme ( int N , int [ ] answerKey , int [ ] studentAnswer ) { int positive = 0 , negative = 0 , notattempt = 0 ; for ( int 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 ) ; } static public void Main ( ) { int [ ] answerKey = { 1 , 2 , 3 , 4 , 1 } ; int [ ] studentAnswer = { 1 , 2 , 3 , 4 , 0 } ; int N = answerKey . Length ; int marking_Scheme = markingScheme ( N , answerKey , studentAnswer ) ; Console . WriteLine ( marking_Scheme ) ; } }