3.11.1
/*存疑*/
#include<stdio.h>
int main() {
int overflow_int = 32767;
float overflow_above_float = 3.4e36;
float overflow_below_float = -3.4e36;
printf("整数上溢的情况是%d", overflow_int + 1);
printf("浮点数上溢的情况是%f", overflow_above_float * 10000.0);
printf("浮点数下溢的情况是%f", overflow_below_float / 10000.0);
}
3.11.2
#include<stdio.h>
int main() {
char ch;
int num;
printf("请输入任意数字:");
scanf_s("%d", &num);
ch = num;
printf("ASCII %d = %c",num,ch);
}
3.11.3
#include<stdio.h>
int main() {
printf("\a");
printf("Startled by the sudden sound, Sally shouted,\n");
printf("\"By the Great Pumpkin, What was that!\"");
}
3.11.4
#include<stdio.h>
int main() {
float num;
printf("Enter a floating-point value:");
scanf_s("%f", &num);
printf("fixed-pointed notation:%f \n", num);
printf("exponential notation:%e \n", num);
printf("p notation:%.2a \n", num);
}
3.11.5
#include<stdio.h>
int main() {
float year,second_year = 3.156e7;
printf("请输入您的年龄:");
scanf_s("%f", &year);
printf("您已经活了%f秒了", second_year * year);
}
3.11.6
#include<stdio.h>
int main() {
float water_quality = 3.0e-23;
float quart;
printf("请输入水的夸脱数:");
scanf_s("%f", &quart);
printf("水的质量是:%eg", quart * 950 / water_quality);
}
3.11.7
#include<stdio.h>
int main() {
float height;
printf("请输入您的身高(英寸):");
scanf_s("%f", &height);
printf("您的身高是%.2fcm", height * 2.54);
}
3.11.8
#include<stdio.h>
int main() {
float cup;
printf("请输入您的杯数:");
scanf_s("%f", &cup);
printf("品脱数为:%.0f\n", cup * 2);
printf("盎司数为: %.0f\n", cup * 2 * 8);
printf("汤匙数为: %.0f\n", cup * 2 * 8 * 2);
printf("茶匙数为: %.0f\n", cup * 2 * 8 * 2 * 3);
}