VowelPhobia

Manish has got the task to frame a speech for his professor at the university at the Annual sports meet.But the problem is that the professor has speech dyslexia and he can't speak the words clearly which have vowels in them. So Manish has to avoid such words and has to minimize their usage in the speech letter. Your task is to help Manish mark the vowels in the words so that he can minimise their use. You are given a string S consisting of lower case letters only. You need to count the number of vowels in the string S.

Example:

Input:  s = "hashes"
Output: 2

Approach

C++

#include <bits/stdc++.h>
using namespace std;

int coutVowels(string s)
{
    int cnt = 0;
    for (int i = 0i < s.size(); i++)
    {
        if (s[i] == 'a' || s[i] == 'e' ||
            s[i] == 'i' || s[i] == 'o' ||
            s[i] == 'u')
            cnt++;
    }
    return cnt;
}
int main()
{

    string s = "hashes";

    cout << coutVowels(s<< "\n";

    return 0;
}


Read Interview Questions

Exception Handling Interview Questions

DBMS Interview Questions Set -1

DBMS Interview Questions Set -2

SQL Interview Question Set -1

SQL Interview Question Set -2

JPA Interview Questions Set -1

JPA Interview Question Set -2

Hibernate Interview Questions

Spring Boot Interview Questions Set 1

Spring Boot Interview Questions Set 2


No comments:

Post a Comment