Sunday, March 17, 2013

Vowel Count In A String

#include<iostream>
using namespace std;
int main()
{
    char jana[30];
    cout<<"Enter a string: ";
    cin.getline(jana,28);
    int i=0,count=0;
    while(jana[i]!='\0')
    {
        switch(jana[i])
        {
            case 'A':
            case 'a':
            case 'E':
            case 'e':
            case 'I':
            case 'i':
            case 'O':
            case 'o':
            case 'U':
            case 'u':
            count++;
        }
        ++i;
    }
    cout<<count;
    return 0;
}

0 comments:

Post a Comment