C Program to Count words, vowels, letters, digits, spaces, Characters in line of Text

C Program to Count number of words, vowels, letters, digits, spaces, Characters in line of Text

This page has a C Program to Count words, vowels, letters, digits, spaces, Characters in line of Text. It is clear that, this C program will find the number of words, vowels, letters, digits, spaces, Characters in a line of Text. The below given C program is used to Count words, vowels, letters, digits, spaces, Characters present in a line of TextKindly check out the program to find the words, vowels, letters, digits, spaces, Characters in any given line of TextThe Questions for find the words, vowels, letters, digits, spaces, Characters problem can be asked as . . .

1). C Program to Count words, vowels, letters, digits, spaces, Characters in line of Text.   

2). C Program to Count Vowels, words, Consonants, Digits and Spaces in Given Text   

3). C Program to count the number of words, characters, alphabets, vowels, consonants and digits in a line of text   

4). C Program to Count letters, Vowels, digits, words, whitespaces and digits in a given string  

5). C Program to Count Vowels, Consonants, words, Digits and Spaces in Given any Text  

6).C Program to Count Vowels, Consonants, words, Digits and Spaces present in any line of Text.   

Count Vowels, Consonants, words, Digits and Spaces Program


    #include<stdio.h>
    int main(){
                  char words[200];
                  int vowels=0, letters=0, word=0, digits=0, spaces=0;
                  int flag=0, i;
                  clrscr();
                  printf("Enter a line of Text :\n");
                  gets(words);
                  for(i=0;words[i]!='\0';++i)
                 {
                 if(words[i]=='a' || words[i]=='e' || words[i]=='i' || words[i]=='o' ||   words[i]=='u' || words[i]=='A' || words[i]=='E' || words[i]=='I' || words[i]=='O' || words[i]=='U')
                 ++vowels;
                 else
                 if((words[i]>='a'&& words[i]<='z') || (words[i]>='A'&& words[i]<='Z'))
                 ++letters;
                 else
                 if(words[i] >='0' && words[i] <='9')
                 ++digits;
                 else
                 if (words[i]==' '){
                 ++spaces;
                 flag=0;}
                 if (words[i] !=' '&& flag==0){
                 ++word;
                 flag=1;
                 }
                 }
                 letters += vowels;
                 printf("\n\n Number of words:  %d", word);
                 printf("\n Number of Digits:  %d", digits);
                 printf("\n Number of Consonants:  %d", letters); 

  //Alphabetic letters 
                 printf("\n Number of Vowels:  %d", vowels);
                 printf("\n Number of White spaces:  %d", spaces);
                 printf("\n Number of Characters:  %d", i);
                 getch();
    return 0;
    }


Sample Output:

Enter a line of Text :
I am '30' years old

Number of words:   5
Number of Digits:   2
Number of Consonants:   11
Number of Vowels:   5
Number of White spaces:   4
Number of Characters:   19


Related Other Popular C Programs

*  Write a c program to check whether a given number is prime number or not?

 

*  Write a C program to find the prime numbers between 1 and 100

 

*  Write a C program to display the prime numbers between a range ?

 

*  Write a C program to find the prime numbers between a range using while loop?

 

*  Write a C program to find the sum of prime numbers between a range 

About Er. T.Tharesh Kumar

I am a Professor and Head of Department of Computer Science in an Arts and Science College. I have designed this website to provide solved example programs of different categories for all the school and college going students to learn C language deeply, and to practice Interview based Multiple Choice (Objective Type) questions and answers.

Other Related C Programs :


* C Program to find whether the given number is Odd or Even

* C Program to find the Sum of Odd Digits

* C Program to find the Sum of Even Digits

* C Program to find the Sum of Even and Odd Digits,

* C Program to Display Odd digits

* C Program to Display even digits

* C Program to Display Odd Numbers,

* C Program to Display Even Numbers,

* C Program to Check whether the given number is Armstrong number

* C Program to display the Armstrong numbers in Range

* C Program to display the Armstrong numbers between 1 and 1000

* C Program to check perfect number, perfect numbers in range

* C Program to Check Prime number, Prime numbers between 1 and 100

* C Program to display the Prime numbers in a Range

* C Program to display the Sum of Prime numbers

* C Program to Check Strong number

* C Program to display the Strong number in Range

* C Program to Check whether the given number is polindrome number or not

* C Program to Check polindrome number using for loop

* C Program to Check polindrome number using Recursion

* C Program to  check whether the given string is polindrome or not

* C Program to find the Roots of Quadratic equation

* C Program to display Fibonacci Series

* C Program to display the Fibonacci Series using an array

* C Program to display the Fibonacci Series using while loop

* C Program to find the Sum of Fibonacci Series, Factorial of Number

* C Program to find the Factorial without using Recursion

* C Program to find the Factorial using Pointers

* C Program to find the Factorial using Function

Bookmark and Share