Advertisement
Nikolay_Kashev

Count letters

Mar 2nd, 2024
1,405
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.38 KB | Software | 0 0
  1. string text = Console.ReadLine();
  2.  
  3. int upperCount = 0;
  4. int lowerCount = 0;
  5. int spaceCount = 0;
  6.  
  7. foreach (char c in text)
  8. {
  9.     if (char.IsUpper(c))
  10.         upperCount++;
  11.     else if (char.IsLower(c))
  12.         lowerCount++;
  13.     else if (char.IsWhiteSpace(c))
  14.         spaceCount++;
  15. }
  16.  
  17. Console.WriteLine(upperCount);
  18. Console.WriteLine(lowerCount);
  19. Console.WriteLine(spaceCount);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement