Friday, February 1, 2019

Vowels

  • Problem Description

    Implement the following algorithm 

    1. Take a string from the user and store it in a variable.
    2. Initialize a count variable to 0.
    3. Use a for loop to traverse through the characters in the string.
    4. Use an if statement to check if the character is a vowel or not and increment the count variable if it is a vowel.
    5. Print the total number of vowels in the string.
    6. Exit
  • CODING ARENA
  • string=input()
    vowels=0
    for i in string:
          if(i=='a' or i=='e' or i=='i' or i=='o' or i=='u' or i=='A' or i=='E' or i=='I' or i=='O' or i=='U'):
                vowels=vowels+1
    print("Number of vowels are")
    print(vowels)

  • Test Case 1

    Input (stdin)
    eLab tool has been used by 40000 users in Tamilnadu alone
    
    
    Expected Output
    Number of vowels are
    
    19
  • Test Case 2

    Input (stdin)
    aeiou aeiou aeiou
    
    
    Expected Output
    Number of vowels are
    
    15

No comments:

Post a Comment