C program to count Occurrence Of Vowels & Consonants In A String

In this tutorial we are going to learn writing C program to count the Occurrence of vowels and consonants in a given string. Here we will have two variables that will store the count. Using if else we will check Vowel and Consonants. If vowel occurs then increase vowel counter other wise increase consonant counter.

You can visit below program for the basic understandings

C program to check given character is vowel or consonants.

How our vowel and consonant counter program works?

  • Our program will take String as an input.
  • We have two integers which will works as the counter of vowel and consonants.
  • Logic will be like if vowel comes increase the counter of vowel by 1. And if consonant comes then increase the counter of consonant by 1.
  • If character is neither vowel nor consonants then do nothing.

C program to count vowel and consonant in string

#include <stdio.h>
#include <string.h>
int main()
	char str[100];
	int i,j,len=0, vowel =0, consonant= 0;
	printf("C program to count vowels and consonants \n");
	printf("Please enter a string : ");
	scanf("%[^\n]", str);
	for(i=0; i<len; i++)
		}else if((str[i]>=65 && str[i]<=90)|| (str[i]>=97 && str[i]<=122)){
	printf("Total number of vowels are : %d and Consonants are : %d",vowel,consonant);
    return 0;


C program to count Occurrence Of  Vowels & Consonants in A String

Share on

Also Prepare Below Important Question

Interview Questions Categories

C Programming Interview Preparation

Core Java Programming Interview Preparation

Python Programming Interview Preparation