#include <iostream.h>
#include <conio.h>
#include<ctype.h>#include<string.h>
void main()
{
char str[100];
int vowel = 0, cons = 0, sp = 0, chr = 0;
for(int i = 0; str[i] != '\0' ; i++)
{
/* count vowels */
if(toupper(str[i])=='A' || toupper(str[i]) == 'E' || toupper(str[i]) == 'I' || toupper(str[i] == 'O' || toupper(str[i]) == 'U' ))
vowel++;
else
{
/* count spaces */
if(str[i] == ' ')
sp++;
else
{
/* count comma or stop as other character */
if(str[i] == '.' || str[i] == ',')
chr++;
else
cons++;
}
}
}
cout<< "\n The original string = " << str;
cout<< "\n The total number of vowels = " << vowel;
cout<< "\n The total number of consonants = " << cons;
cout<< "\n The total number of balnk spaces = " << sp;
cout<< "\n The total number of other characters like comma or full-stops =" << chr;
int l = strlen(str);
cout<< "\n The string in reverse is ";
for(i=l-1; i>=0 ; i--)
cout<< str[i];
getch();
}
No comments:
Post a Comment