C-Program to Count number of Vowels using Pointers

C - Program to count number of Vowels in a string using Pointers. 


#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
    char st[100], *sptr;
    int count = 0;
    printf("\n Enter the String: \n");
    gets(st);
    sptr = st;
    /* loop to count vowels */
    while(*sptr != '\0')
    {
        switch(*sptr)
        {
            case 'A':
            case 'a':
            case 'E':
            case 'e':
            case 'I':
            case 'i':
            case 'O':
            case 'o':
            case 'U':
            case 'u':  count++;
                        break;
        }
        sptr++;
    }
    printf("\n Number of vowel = %d \n\n",count);
}



OUTPUT:


Post a Comment

0 Comments