Friday, May 30, 2014

WRITE A PROGRAMME TO COUNT NO OF VOWELS,CONSONANTS AND NO OF DIGITS IN A STRING

#include<conio.h>
#include<stdio.h>
void main()
{
char ar[20];
int v=0,c=0,d=0,i=0;
clrscr();
printf("enter the string\n");
gets(ar);
while(ar[i])
{
if(ar[i]!=32)
{
if(ar[i]>='0'&&ar[i]<='9')
d++;
else if(ar[i]=='a'||ar[i]=='e'||ar[i]=='i'||ar[i]=='o'||ar[i]=='u')
v++;
else
c++;
}
i++;
}
printf("\nno of vowels in %s are-%d",ar,v);
printf("\nno of consonants in %s are-%d",ar,c);
printf("\nno of digits in %s are-%d",ar,d);
getch();
}

No comments:

Post a Comment