// Count the number of alphabets, spaces, digits and other characters in one line character
#include<stdio.h>
void main()
{
char c;
int i = 0 ,j = 0, m = 0, n = 0;
printf("Please input one line characters:\n\n");
while((c = getchar()) != '\n')
{
if ((c >= 'a' && c <= 'z')||(c >= 'A' && c <= 'Z'))
++i;
else if (c == 32)
++j;
else if (c >= '0' && c <= '9')
++m;
else ++n;
}
printf("\n");
printf("The number of alphabets are %d\n\n",i);
printf("The number of spaces are %d\n\n",j);
printf("The number of digits are %d\n\n",m);
printf("The number of other characters are %d\n\n",n);
}
Count the number of alphabets, spaces, digits and other characters in one line character
最新推荐文章于 2022-11-22 11:07:48 发布