pTutorial

New way to learn C programming

C Program to Count number of vowel

This is a user-defined C program to count the number of vowels in an entered string without using any pre-defined function.

Count number of vowel in entered string


#include <stdio.h>
#include <conio.h>
void main(){
    char z[20];
    int i,k=0;
    printf("Please enter a string:\n");
    gets(z);
  
    for(i=0;z[i]!='\0';++i)
    {
        if(z[i]=='a' || z[i]=='e' || z[i]=='i' || z[i]=='o' || z[i]=='u'  )
            k++;
            
         if(z[i]=='A' || z[i]=='E' || z[i]=='I' || z[i]=='O' || z[i]=='U')
            k++;
    }
    printf("Total length of string is: %d",i);
    printf("\nAnd number of vowel is: %d",k);
    
}


Download Count numbers of vowel

Output of program

C program to Count the number of vowel

In the above example "z" is a character type array variable that holds the entered string and a for loop run until or unless "\o" character found that represent the end of the string. By using if checks characters one by one whether it is the vowel or not, if it is then increased 1 in "k" variable otherwise do nothing.

See Also

Bootstrap log in form example   |   Required field validation using jquery   |   Example angular.php

QUOTES OF THE DAY

Beauty is truth, Truth beauty- That is all

LIKE ON FACEBOOK

+1 ON GOOGLE

SHARE ON TWITTER