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- A. 3 7 4 4
- B. 2 8 4 4
- C. 2 8 4 3
- 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.
Practise more Pseudocode and Code Tracing questionsPseudocode and Code Tracing: notes and key points
More Pseudocode and Code Tracing questions
- What will be the output of the following pseudocode? String s = "AAAAA", r = "" Integer i = 0 while (i < length(s)) if (i + 1 < length(s)…
- What will be the output of the following pseudocode? (code(c) gives the ASCII code: 'A' = 65, 'a' = 97, '0' = 48; ^ is XOR) Integer x =…
- What will be the output of the following pseudocode? (| is OR, & is AND, << and >> are shifts) String s = "THE QUICK BROWN FOX" Integer…
- What will be the output of the following pseudocode? (Arrays are indexed from 0; abs gives the absolute value) Integer a[8] = {4, 3, 2, 7…
- What will be the output of the following pseudocode? (Arrays are indexed from 0) Integer a[4] = {3, 4, -1, 1}, n = 4 for (each i from 0 to…
- What will be the output of the following pseudocode? (Arrays are indexed from 0) Integer a[3] = {1, 3, 8}, b[4] = {2, 7, 9, 10}, c[7]…