Neema,SEE model question set 8(issued by CDC)

Q.11 Debug the given program

REM to count total number of even values existing among n different number input by a user
declare function evencount(a(),n)
CLS
FOR CNT = 0 TO n - 1
   INPUT "Enter the number"; a(n)
NEXT CNT
totevenno = evencount(a())
PRINT "Total number of even values existing."; totevenno
END
FUNCTION evencount ()
  count = 0
   FOR CNT = 0 TO n - 1
     IF a(CNT) MOD 2 = 0 THEN count = count + 1
  NEXT CNT
   count = evencount
END FUNCTION

Debugged program:-


REM to count total number of even values existing among n different number input by a user
declare function evencount(a(),n)
CLS
INPUT "Enter any number"; n
FOR CNT = 0 TO n - 1
   INPUT "Enter the number"; a(CNT)
NEXT CNT
totevenno = evencount(a(), n)
PRINT "Total number of even values existing."; totevenno
END
FUNCTION evencount (a(), n)
   count = 0
   FOR CNT = 0 TO n - 1
     IF a(CNT) MOD 2 = 0 THEN count = count + 1
   NEXT CNT
   evencount = count
END FUNCTION



Previous
Next Post »

Watermark free kinemaster

DOWNLOAD