ProgrammingModerateSSC CGL Tier 2 · IBPS PO Mains

The procedure below counts the uppercase letters in the sentence "Hello World From AI". What is printed?

The procedure below counts the uppercase letters in the sentence "Hello World From AI". What is printed?
count = 0
for each character c
    if c is an uppercase letter then count = count + 1
end for
Print count
  1. A. 5
  2. B. 11
  3. C. 3
  4. D. 16

Correct answer: A. 5

The capitals are H, W, F, A and I, which is 5. Counting lowercase letters gives 12, counting the spaces gives 3, and counting all letters gives 17.

More Pseudocode and Code Tracing questions

Exams that ask this topic