In online journal system, the user has to give detail information about their abstract of the manual script before upload of source document. The abstract submitted by the author should not more than 300 words. The journal system uses program to count the number of vowels, consonants, digits and symbols in a given paragraph. Write a program to count the number of vowels, consonants, digits and symbols using pointers as reference to the function.
Runtime Input :
1=>see-programming.blogspot.com
Output :
No. of vowels: 8
No. of consonants: 17
No. of digits: 1
No. of symbols: 1
Others: 4
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char* argv[])
{
char str[1000];
int i,v,c,d,s,o;
gets(str);
v = 0;
c = 0;
d = 0;
s = 0;
o = 0;
for (i = 0; i < strlen(str); i++)
{
if (str[i] >= ' ')
{
if (str[i] == '-')
s++;
else if (str[i] >= '0' && str[i] <= '9')
d++;
else if ((str[i] >= 'A' && str[i] <= 'Z') || (str[i] >= 'a' && str[i] <= 'z'))
{
if (str[i] == 'A' ||
str[i] == 'E' ||
str[i] == 'I' ||
str[i] == 'O' ||
str[i] == 'U' ||
str[i] == 'a' ||
str[i] == 'e' ||
str[i] == 'i' ||
str[i] == 'o' ||
str[i] == 'u')
v++;
else
c++;
}
else
o++;
}
}
printf("No.of vowels : %d\n",v);
printf("No.of consonants : %d\n",c);
printf("No.of digits : %d\n",d);
printf("No.of symbols : %d\n",s);
printf("Others : %d\n",o);
return 0;
}
Comments
Leave a comment