c语言如何判断输入字母个数,C语言 输入一个字符,判断该字符是数字、字母、空格还是其他字符。...

三个空分别是:

1、ch >= 'a'&&ch<='z' || a>='A'&&ch<='Z'

2、 ch >= '0' && ch<='9'

3、 ch == ' '

4、完整代码

#include

#include int main()

{

char ch;

printf("Please enter a char:");

while((ch=getchar())!=EOF)

{

if(ch>='0'&&ch<='9')

{

printf("%c是数字字符:",ch);

}

else if(ch>='a'&&ch<='z')

{

printf("%c是小写字母:",ch);

}

else if(ch>='A'&&ch<='Z')

{

printf("%c是大写字母:",ch);

}

else if(ch==' ')

{

printf("%c是空格:",ch);

}

else

{

printf("%c是其它字符:",ch);

}

}   return 0;

}

d8c0c638096e8b8d95229d08dd366d27.png

扩展资料

C语言特有特点

1、C语言是一个有结构化程序设计、具有变量作用域(variable scope)以及递归功能的过程式语言。

2、C语言传递参数均是以值传递(pass by value),另外也可以传递指针(a pointer passed by value)。

3、不同的变量类型可以用结构体(struct)组合在一起。

4、只有32个保留字(reserved keywords),使变量、函数命名有更多弹性。

参考资料

百度百科-C语言