VOWELS, CHARACTERS, DIGITS, BLANK SPACES, WORDS - C-Tutorial

Latest

Monday, 26 September 2016

VOWELS, CHARACTERS, DIGITS, BLANK SPACES, WORDS

/* VOWELS, CHARACTERS, DIGITS, BLANK SPACES, WORDS */



#include<stdio.h>
#include<conio.h>
#include<ctype.h>
main()
{
char ch;
int v=0,c=0,d=0,w=0,bs=0,sp=0;
clrscr();
printf("\n\n Enter a line of text :");
while((ch=getchar()) != '\n')
{
ch=tolower(ch);
if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u')
v=v+1;
else if(ch>='a' && ch<='z')
c=c+1;
else if(ch>='0' && ch<='9')
d=d+1;
else if(ch==' ' || ch=='\t')
{
bs=bs+1;
w=w+1;
}
else
sp=sp+1;
}
printf("\n The no.of vowels : %d",v);
printf("\n The no.of characters : %d",c);
printf("\n The no.of digits : %d",d);
printf("\n The no.of blank spaces : %d",bs);
printf("\n The no.of words : %d",w+1);
printf("\n The no.of special symbols : %d",sp);
getch();
}

No comments:

Post a Comment