程序代码
#include <stdio.h>
#include <stdlib.h>
/*
*csdn学院——2016级
*文件名称:Myfun12.c
*作者:小臣小仁
*完成日期:2016年11月4日
*问题描述:编写一个程序,
*从键盘上输入一个小写字母,
*显示这个小写字母及它所对应
*的大写字母以及它们的ASCII码值。
*/
int main()
{
char cLetter;
printf("请输入一个小写字母:");
scanf("%c",&cLetter);
printf("小写字母%c的ASCLL码值%d\n",cLetter,cLetter);
printf("大写字母%c的ASCLL码值%d\n",cLetter-32,cLetter-32);
return 0;
}
输出结果
知识点总结:
当我们输入一个字符型char,并以一个整形int输出,系统默认会将字母转换为相对应的ASCLL码码值输出。
心得体会:
学会了如何利用字符进行数值运算。