ProgrammingHardCognizant GenC Next · Accenture

What will be the output of the following pseudocode?

What will be the output of the following pseudocode?
String s = "Tcs NQT 2024 Exam!"
Integer v = 0, c = 0, d = 0, o = 0
for (each ch in s)
    if (ch is a letter)
        if (lowercase(ch) is one of a, e, i, o, u)
            v = v + 1
        else
            c = c + 1
        end if
    else if (ch is a digit)
        d = d + 1
    else
        o = o + 1
    end if
end for
Print v, c, d, o
  1. A. 3 7 4 4
  2. B. 2 8 4 4
  3. C. 2 8 4 3
  4. D. 2 7 4 3

Correct answer: B. 2 8 4 4

Letters: T, c, s, N, Q, T, E, x, a, m — vowels E and a (2), consonants 8. Digits 2, 0, 2, 4 (4). Others: three spaces and ! (4). Output 2 8 4 4.

More Pseudocode and Code Tracing questions

Exams that ask this topic