cmi-entrance 2025 Q16

cmi-entrance · India · mscds Not Maths
16. In the following code the operator \% denotes the remainder after integer division. That is: for positive integers $\mathrm { a } , \mathrm { b }$ the value $\mathrm { a } \% \mathrm {~b}$ is the remainder obtained when a is divided by b .
\begin{verbatim} function fizzbuzz(n) { count = 0; for i from 0 to (n-1) { if ((i % 3) == 0) and ((i % 5) != 0) { count = count + 1; } } return(count); } \end{verbatim}
What does fizzbuzz(100) return?
(a) 27
(b) 33
(c) 45
(d) 60
16. In the following code the operator \% denotes the remainder after integer division. That is: for positive integers $\mathrm { a } , \mathrm { b }$ the value $\mathrm { a } \% \mathrm {~b}$ is the remainder obtained when a is divided by b .

\begin{verbatim}
function fizzbuzz(n) {
    count = 0;
    for i from 0 to (n-1) {
            if ((i % 3) == 0) and ((i % 5) != 0) {
                count = count + 1;
        }
    }
    return(count);
}
\end{verbatim}

What does fizzbuzz(100) return?\\
(a) 27\\
(b) 33\\
(c) 45\\
(d) 60\\