Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4. "fmt"
  5. )
  6.  
  7. func main() {
  8.  
  9. text := `The quick brown fox jumps over the lazy dog`
  10. vowels, spaces, constants := 0, 0, 0
  11.  
  12. for _, char := range text {
  13. switch char {
  14. case 'a', 'e', 'i', 'o', 'u':
  15. vowels++
  16. case ' ':
  17. spaces++
  18. default:
  19. constants++
  20. }
  21. }
  22.  
  23. fmt.Printf("Found %d vowels, %d spaces and %d constants", vowels, spaces, constants)
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement