-->
Showing posts with label WAP to count total number of vowels in a string.. Show all posts
Showing posts with label WAP to count total number of vowels in a string.. Show all posts

WAP to count total number of vowels in a string.

in turboc++
--------------------------------------------------------------------------------------
//program to count total vowels in a string.
#include <stdio.h>
#include<string.h>
#include<conio.h>
int main()
{
    char string[100],sec;
    int i,count=0;       //initialization
    printf("enter string\n");
    gets(string);//accepts string
    strlwr(string);//converts the string into lowercase
    for(i=0;string[i]!='\0';i++)//loop execution till null character
    {
        if(string[i]=='a' || string[i]=='e'|| string[i]=='i'|| string[i]=='o' ||string[i]=='u')
                                            //condition testing for character/vowels
        {
            count++;//counting  words
        }
    }
    printf("total vowels=%d",count);// prints total vowels.
    getch();
    return 0;
}

----------------------------------------------------------------------------------
in codeblocks:
---------------------------------------------------------------------------------------------------------------
//program to count total vowels in a string.
#include <stdio.h>
#include<string.h>
int main()
{
    char string[100],sec;
    int i,count=0;       //initialization
    printf("enter string\n");
    gets(string);//accepts string
    strlwr(string);//converts the string into lowercase
    for(i=0;string[i]!='\0';i++)//loop execution till null character
    {
        if(string[i]=='a' || string[i]=='e'|| string[i]=='i'|| string[i]=='o' ||string[i]=='u')
                                            //condition testing for character/vowels
        {
            count++;//counting  words
        }
    }
    printf("total vowels=%d",count);// prints total vowels.
    return 0;
}