2.编写一个程序,要求提示输入一个ASCII码值(如,66),然后打印输入的字符。
#include <stdio.h>
int main(void)
{
char ch;
printf("Enter the ASCII:");
scanf("%d\n",&ch);
printf("The character is:%c\n",ch);
return 0;
}
注:char类型也是整数类型 ,所以可以用%d转换说明输入,也可以用%c转换说明显示。
3. 编写一个程序,发出一声警报,然后打印下面的文本:Startled by the sudden sound, Sally shouted, "By the Great Pumpkin, what was that!"
#include <stdio.h>
int main(void)
{
printf("\a");
printf("Startted by the sudden sound,sally Shouted,\n");
printf("\"By the Great Pumpkin,what was that!\"\n");
return 0;
}
注:\a是转义系列,表示发出一声警报。为避免混淆,打印双引号字符”,应使用转义系列\“。
4.编写一个程序,读取一个浮点数,先打印成小数点形式,再打印成指数形式。然后,如果系统 支持,再打印成p记数法(即十六进制记数法)。按以下格式输出(实际显示的指数位数因系统而异)