从键盘输入任意一个字符,如果输入的是:0~9之间的字符,则打印输出:"It is a number.";若输入的是:+、-、*、/中的运算符,则打印输出:"It is an operator.";若输入的是其它字符,则打印输出:"It is another character."。 **输入提示信息**:"Please enter a character:\n" **输入数据格式**:"%c" **输出数据格式**: 若输入0~9之间的字符,则输出格式是:"It is a number." 若输入的是+、-、*、/运算符,则输出格式是:"It is an operator." 如输入的是其它字符,则输出格式是:"It is another character."
#include<stdio.h>
int main()
{
char ch;
printf("Please enter a character:\n");
scanf("%c", &ch);
if (ch >= '0' && ch <= '9')
{
printf("It is a number.");
}
else if (ch == '+' || ch == '-' || ch == '*' || ch == '/')
{
printf("It is an operator.");
}
else
{
printf("It is another character.");
}
return 0;
}