Friday, 19 December 2025

Project for Students: Create a code to check the marks obtained by a student when there is negative marking for wrong attempts.

 Here is the code :


!=================================

program negativermkv

implicit none

integer :: right, wrong ,didnotdo,totalmarks,notattemp

integer, parameter :: qnumber=25

integer, parameter :: marks_for_correct=4

integer, parameter :: marks_for_wrong=-1

write(*,'(A10, A10, A10, A13, A13)') 'right','wrong','notattemp','didnotdo','totalmarks'

do didnotdo=0,qnumber,1   ! didnotdo includes wrong+did not attemp

do wrong = 0,didnotdo,1

right = qnumber - didnotdo 

notattemp=didnotdo-wrong 

totalmarks = right*marks_for_correct + wrong*marks_for_wrong + didnotdo*0

write(*,23)right,wrong,notattemp,totalmarks

23 format(100(I3,1x))

end do

end do

end program

!=============================

How to run this code?
gfortran codefile.f90
./a.out


Regards,
Somenath Jalal
19.12.2025
11:44 PM


No comments:

Post a Comment

Note: only a member of this blog may post a comment.

  # Set up the 3D view and axis labels set view 15, 50 set xlabel "X" set ylabel "Y" set zlabel "Z" # Set the ...