C program to count the vowels in a string - My CS Tutorial - My CS Tutorial

Breaking

Programming languages full tutorial and programs, exam papers, visual basic( Vb.net ), information of new technologies and more....

Sunday, January 12, 2020

C program to count the vowels in a string - My CS Tutorial

C program to find or count the vowels in a given string or sentence.
In this tutorial we will discuss that how to write a simple c program to find the vowels in a string.


C program code


#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
    int i,vowelcount=0;
    char str[100];
    clrscr();
    
    printf("\n ENTER A STRING OR SENTENCE:\n ");
    gets(str);
    for(i=0;i<strlen(str);i++)
    {
        if(str[i]=='A'||str[i]=='a'||str[i]=='e'||str[i]=='E'||str[i]=='I'
        ||str[i]=='i'||str[i]=='O'||str[i]=='o'||str[i]=='U'||str[i]=='u')
        {
            vowelcount++;
        }
    }
    
    printf("\n VOWELS ARE PRESENT IN THIS STRING IS:%d\n",vowelcount);

getch();
}


OUTPUT:




Please share this post and blog link with your friends.For more programs use this blog.
If you have any problem, please comment in comment box, subscribe this blog for notifications of new post on your email and follow this blog.If you have any method of this program or want to give any suggestion send email on hc78326@gmail.com

Created by-- HARSH CHAUHAN

No comments:

Post a Comment