C Programming (Fifth Edition) Example 4.4

C Programming (Fifth Edition) Example 4.4

The following is a different method from the textbook

Enter a character and determine whether it is an uppercase letter, if it is, convert it to a lowercase letter; if it is not, do not convert it. Then output the final character.

#include<stdio.h>
int main()//C语言需要的格式
//由题意可判断此题需要条件表达式处理
{
    
    
char ch;//因为输入为字符,用char定义
scanf("%c",&ch);//因为输入为字符,使用%c;不要缺少符号&
if(ch>='A'&&ch<='Z')
/*此处判断输入字符的大小写
符号&&的意思是且,即两边条件都要满足*/
ch=ch+32;//如果为大写字母,则ch加上32,再赋值给ch
printf("%c",ch);
return 0;
}

Guess you like

Origin blog.csdn.net/weixin_51057554/article/details/109402004