程序如下:
#include
int main()
{
char ch;
scanf("%c",&ch);
printf("%c",ch-'a'+'A');
return(0);
}
示例一:
#include
int main()
{
char ch;
scanf("%c",&ch);
printf("Letter %c converted into a letter %c!",ch,ch-32);//大写字母ASCII码比小写字母小32
return 0;
}
示例二:
ch=getchar();
if(ch>='a'&&ch<='z')
{ch=ch-32;
prinft("大写字母是:%c\n",ch);
}
else(printf("请输入大写字母");
)
示例三:
#include
main()
{
char c; //声明变量
scanf("%c",&c); //键盘上取值
printf("%c %c",c,ch-'a'+'A');//本身和大写输出
}