Count Consonants In A String Given a string ‘STR’ which consists of uppercase and lowercase characters and spaces. Count the number of consonants in the string. A consonant is an English alphabet character that is not vowel (a, e, i, o, and u). Examples of constants are b, c, d, f, etc. Example : Given string 'STR&...

read more
CodingNinjas
author
2y
1. Get the string on which count has to be performed.2. Run a loop from 0 to the length of the string.3. Take a single character at a time and verify if they are a part of the group of vowels.4. If th...
see more
CodingNinjas
author
2y
Recursive ApproachIf we can find if the current character is a consonant or not we can create a recursive to count all the vowels. Let ‘i’ be the index of the current character we are at and ‘N’ ...
see more
CodingNinjas
author
2y
Iterative ApproachWe can simply check if every element is a consonant or not and keep the count of the number of consonants using a simple for loop. Here is the algorithm : Create a variable...
see more
Add answer anonymously...
TCS Graduate Trainee Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2023 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter