C language programming third edition Su Xiaohong 5.7 keyboard input characters, change uppercase letters to lowercase letters, lowercase letters to uppercase letters, and output ASCII codes

#include<stdio.h>
int main()
{
char ch;
printf(“从键盘输入一个字符:\n”);
ch=getchar();
if(ch>=‘A’ && ch<=‘Z’)
ch=ch+32;
else if(ch>=‘a’ && ch<=‘z’)
ch=ch-32;
printf("%c %d\n",ch,ch);
return 0;
}

Guess you like

Origin blog.csdn.net/weixin_43462140/article/details/91128354