Here is a C program for Counting vowels, consonants, digits, special characters & words in a given string. This program uses C concepts like While Loop, Strings in C, Gets Function. This program also uses CTYPE.H Header File in C.
# include <stdio.h> # include <conio.h> # include <ctype.h> void main() { char text[80], ch ; int vowel = 0, cons = 0, digit = 0, word = 0, special = 0, i = 0; clrscr() ; printf("Enter the text : ") ; gets(text) ; while((ch = tolower(text[i++])) != '\0') { if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u') ++vowel ; else if(ch >= 'a' && ch <= 'z') ++cons ; else if(ch >= '0' && ch <= '9') ++digit ; else if(ch == ' ') ++word ; else ++special ; } ++ word ; printf("\nThe text contains : ") ; printf("\n\nNumber of vowels = %d", vowel) ; printf("\n\nNumber of consonants = %d", cons) ; printf("\n\nNumber of digits = %d", digit) ; printf("\n\nNumber of special characters = %d", special) ; printf("\n\nNumber of words = %d", word) ; getch() ; }
Output of above program
Enter the text : Tanmay was born on 22nd Oct 1989 !!!
The text contains :
Number of vowels = 6
Number of consonants = 14
Number of digits = 6
Number of special characters = 3
Number of words = 8
Hello There,
A spot on observation on what probably is “the” underlying details of the Program to Count Vowels, Consonants, Digits, Specials and Words in a String in C.Too many people don’t even think about wherever there will be actual demand and more importantly what happens if this demand comes later (or maybe a lot later) than they expect
i didn't know what title to put so i put that one, sorry for not being clear.
My problem is that i'm making my own shell, which uses the regular system commands, such as cd, ls, date,... and i'm looking for a way that it identifies !2 and executes the second command in the history, (the number is an example)
I hace made some code in which it executes what i ask BUT in this form ! 2, and i need the ! to be next to the 2
But nice Article Mate! Great Information! Keep up the good work!
Many Thanks,
Preethi