//第 1 题
#include <stdio.h>
#include <float.h>
#include <limits.h>
int main(void)
{
int big_int = 2147483647;
float big_float = 3.4e38;
float small_float = 10.0 / 3;
printf("The big int data is %d\n", big_int + 1);
printf("The big float data is %f\n", big_float * 10);
printf("The big float data is %f\n", small_float);
printf("The MAX float data is %f\n", FLT_MAX);
printf("The MAX int data is %ld\n", INT_MAX);
return 0;
}
//第 2 题
#include <stdio.h>
int main(void)
{
int input;
printf("Enter a value of char int ASCII:");
scanf("%d", &input);
printf("You input value is %d,and char is %c\n", input, input);
return 0;
}
//第 3 题
#include <stdio.h>
int main(void)
{
char ch = '\a';
printf("%c", ch);
printf("Starled by the sudden sound, Sally shouted, \n");
printf("\"By the Great Pumpkin, what was that!\"\n");
return 0;
}
//第 4 题
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(void)
{
float input;
printf("Enter a floating-point value.");
scanf("%f", &input);
printf("fixed-point notation: %f \n", input);
printf("exponential notation: %e \n", input);
printf("p notation: %a \n", input);
return 0;
}
//第 5 题
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#define SEC_PER_YEAR 3.156e7
int main(void)
{
float second, year;
printf("Enter how many years old you are:");
scanf("%f", &year);
second = year * SEC_PER_YEAR;
printf("You are: %.1f years old.\n", year);
printf("And you are %e seconds old, too.\n", second);
return 0;
}
//第 6 题
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#define MASS_PER_MOLE 3.0e-23
#define MASS_PER_QUART 950
int main(void)
{
float quart, quantity;
printf("Enter how many quart:");
scanf("%f", &quart);
quantity = quart * MASS_PER_QUART / MASS_PER_MOLE;
printf("There are %e molecule.\n", quantity);
return 0;
}
//第 7 题
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#define INCH_TO_CM 2.54
int main(void)
{
float inch, cm;
printf("Enter the inch of your heigh:");
scanf("%f",&inch);
cm = inch * INCH_TO_CM;
printf("Hi ,your are %0.2f inch ,or 8.2f cm heigh\n", inch, cm);
return 0;
}
//第 8 题
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#define PINT_CUP 2
#define CUP_OUNCE 8
#define OUNCE_SPOON 2
#define SPOON_TEA 3
int main(void)
{
float pint, cup, ounce, spoon, tea_spoon;
printf("Enter how many cup:");
scanf("%f", &cup);
pint = cup / PINT_CUP;
ounce = cup * CUP_OUNCE;
spoon = ounce * OUNCE_SPOON;
tea_spoon = spoon * SPOON_TEA;
printf("%.1f cup equals %.1f pint, %.1f ounce, %.1f spoon, %.1f tea spoon. \n",
cup, pint, ounce, spoon, tea_spoon);
return 0;
}