Computer Science, asked by kashwini77, 2 months ago

Write a program to count the number of vowels in a string “Informatics Practices” ?​


anindyaadhikari13: Please mention the programming language.

Answers

Answered by anindyaadhikari13
3

Required Answer:-

Question:

  • Write a program to count the number of vowels in string "Informatics Practices"

Solution:

Here is the program. This is written in Python.

s="Informatics Practices"

c=0

for i in range(len(s)):

if s[i] in "aeiouAEIOU":

c+=1

print("Number of vowels: ",c)

Explanation:

  • We will store the string in s variable. Now, we will extract each characters and check if it is a vowel or not. If it is a vowel, then the value of c is incremented by 1. At last, c is displayed on the screen.

Output is attached.

Attachments:

anindyaadhikari13: Do you want the program in any other language?
Answered by Oreki
3

Program

   count = 0

   for letter in "Informatics Practices".lower( ):

       if letter in "aeiou":

           count += 1

   print("Total number of vowels -", count)

Algorithm

  • Iterating over the string and checking the letter is a vowel or not.
  • If a letter is a vowel then incrementing the counter variable by 1.
  • Printing the final value of the counter variable.
Attachments:

ⲎσⲣⲉⲚⲉⲭⳙⲊ: Great answer :-)
Oreki: Thanks!
anindyaadhikari13: Superb!
Similar questions