All challenges
Easy 0 solved 0% acceptance

Count Uppercase Letters

Count the capital letters in a text.

Problem

Count how many characters in text are uppercase English letters A–Z.

Implement count_uppercase(text).

Input

text: The text to inspect.

Output

Return the number of uppercase letters.

Constraints

0 ≤ length of text ≤ 10,000 (ASCII characters)

Examples

Example 1
Input:
text = "Hello World"

Expected output:
expected = 2
Input:
std::string text = "Hello World";

Expected output:
long long expected = 2;
Input:
string text = "Hello World";

Expected output:
long expected = 2;

Explanation

H and W are uppercase: 2.

Example 2
Input:
text = "no caps here!"

Expected output:
expected = 0
Input:
std::string text = "no caps here!";

Expected output:
long long expected = 0;
Input:
string text = "no caps here!";

Expected output:
long expected = 0;

Explanation

There are no uppercase letters: 0.

References

This challenge is adapted for CodeUtility. Follow the statement and constraints above.

Learn from others

Community solutions

No published solutions yet. Solve this challenge to share the first one.