Monday, 23 January 2012

Write a C program to count the vowel in a string

#include<stdio.h>
#include<conio.h>
#include<string.h>

void main()
{
    char a[100];
    int ct=0,i,l;
    clrscr();
    printf("Enter the string\n");
    gets(a);
    l=strlen(a);
    for(i=0;i<l;i++)
    {
        if(a[i]=='a'||a[i]=='e'||a[i]=='i'||a[i]=='o'||a[i]=='u'||a[i]=='A'||a[i]=='E'||a[i]=='I'||a[i]=='O'||a[i]=='U')
        {
            ct=ct+1;
        }
    }
    printf("Number of vowel in the string=%d",ct);
    getch();
}

No comments:

Post a Comment