write a c program to count vowels and consonants in a string,write a program to count the number of vowels and consonants in a string,vowels and consonants in c program
Write a c program to count vowels and consonants in a string
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char s[50];
int l,i,cons=0,vow=0;
clrscr();
printf("Enter your name: ");
gets(s);
l=strlen(s);
for(i=0;i<l;i++)
if(isalpha(s[i]))
switch(toupper(s[i]))
{
case
'A':
case
'E':
case
'I':
case
'O':
case
'U': vow++;
break;
default:
cons++;
}
printf("Number of vowels in your name=%d\n",vow);
printf("Number of consonants in your
name=%d",cons);
getch();
}
Output:
Enter your name: Hanumanth
Number of vowels in your name=3
Number of consonants in your name=6
No comments: