A simple program that I wrote using C programming language to ask the user to give a string and then the program will count the number of vowels, and consonants and display the results on the screen.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website, kindly contact me also at my email address also. Thank you.

My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.

Program Listing

/* vowels_consonants.c
 Author : Prof. Jake Rodriguez Pomperada, MAED-IT, MIT
 Websites : www.jakerpomperada.com and www.jakerpomperada.blogspot.com
 Email : jakerpomperada@gmail.com
 Tool  : Dev C++ 5.11
 Location : Bacolod City, Negros Occidental Philippines
*/

#include <stdio.h>
#include <string.h>


int i=0,a=0,vowels=0,consonants=0;
char str[100];

void main()
{
	
	printf("\n\n");
	printf("\tCount Vowels, and Consonants in C");
	printf("\n");
	printf("\nGive a String : ");
    scanf("%s",&str);
     for (i = 0; i < strlen(str); ++i)
    {
        str[i]=toupper(str[i]);
    }
	for(i=0;str[i]!='\0';i++)
	{
	    
  if(str[i]=='A' | str[i]=='E' | str[i]=='I' | str[i]=='O' | str[i]=='U')
		{
			a++;
			vowels++;
			printf("\n %d. The Vowels is: %c",a,str[i]);
		}
		else
		{
			a++;
			consonants++;
			printf("\n %d. The Consonants is: %c",a,str[i]);
		}
	}
    printf("\n");
	printf("\n\nThe Total Number of Vowels : %d",vowels);
	printf("\nThe Total Number of Consonants  : %d",consonants);
	printf("\n\n");
	printf("\tEnd of Program");
	printf("\n\n");
} /* End of Code */

Leave a Reply

Your email address will not be published. Required fields are marked *