1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
int main(void)
{
char *p, words[81];
int i=0, c=0, a;
int digitCounter =0, spaceCounter =0, punctCounter =0, alphaCounter =0;
printf("\nEnter your words : ");
gets(words);
printf("\nThe input is : %s",words);
c = strlen(words);
printf("\nThe size is: %d",c);
p = & words [c-1];
printf("\nThe reverse order :");
for (i = c-1; i>=0 ; i--)
{
printf("%c", words[i]);
}
for (i=0;i<c; i++)
{
if(isdigit(words[i])) digitCounter++;
else if (isspace(words[i])) spaceCounter++;
else if (isalpha(words[i])) alphaCounter++;
else if (ispunct(words[i])) punctCounter++;
}
printf("\n it contains %d digits, %d spaces, %d punctuations, %d alphas\n", digitCounter, spaceCounter, punctCounter, alphaCounter);
} |
Partager