Skip to content
Programmingoneonone
Programmingoneonone
  • Home
  • CS Subjects
    • IoT – Internet of Things
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programmingoneonone

C Program to find occurrences of vowels, consonants, words, spaces, and special characters in the given sentence

YASH PAL, 31 July 2024

In this tutorial, we are going to write a C Program to find the number of occurrences of vowels, consonants, words, spaces, and special characters in the given sentence in C Programming with practical program code and step-by-step full complete explanation.

C Program to find occurrences of vowels, consonants, words, spaces, and special characters in the given sentence

C Program code.

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

void main()
{
	char s[100];
	int vow=0,cons=0,spc=0,punc=0,l,i;

	clrscr();

	printf("Enter the statementn");

	gets(s);
	l=strlen(s);

	for(i=0;i<l;i++)
	{
		if(isalpha(s[i]))
		{
			if(s[i]=='a' || s[i]=='e' || s[i]=='i' || s[i]=='o' || s[i]=='u')
			{
				vow++;
			}
			else
			{
				cons++;
			}
		}
		if(isspace(s[i]))
		{
			spc++;
		}

		if(ispunct(s[i]))
		{
		punc++;
		}	
	}

	printf("nNumber of words=%d",spc+1);
	printf("nNumber of vowels=%d",vow);
	printf("nNumber of consonants=%d",cons);
	printf("nNumber of space=%d",spc);
	printf("nNumber of special characters=%d",punc);

	getch();
}

Output

 
Enter the statement
*Nothing is impossible in the world.
Number of words=6
Number of vowels=10
Number of consonants=19
Number of space=5
Number of special characters=1
c coding problems

Post navigation

Previous post
Next post
  • How AI Is Revolutionizing Personalized Learning in Schools
  • GTA 5 is the Game of the Year for 2024 and 2025
  • Hackerrank Day 5 loops 30 days of code solution
  • Hackerrank Day 6 Lets Review 30 days of code solution
  • Hackerrank Day 14 scope 30 days of code solution
©2025 Programmingoneonone | WordPress Theme by SuperbThemes