Thursday, 21 December 2017

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:


No comments:

Post a Comment

Featured Post

TCS Latest Test Patern ( For On-Campus Drives )

Tata Consultancy Services is software services consulting company whose  headquarter is situated in Mumbai, India. It is the Asia’s larges...