T1.
#include <stdio.h>
#include <limits.h>
#include <float.h>
int main(){
int max_int = INT_MAX;
float min_float = 0.1111e-38/10;
float max_float = FLT_MAX;
printf("The maximum integer value is %d\n", max_int+1);
printf("The underflow float value is %e\n", min_float);
printf("The maximum float value is %f\n", max_float);
printf("The overflow float value is %f\n", max_float*10);
return 0;
}
T2.
#include <stdio.h>
int main(void)
{
int ch;
printf("Enter a ASCII character: ");
scanf("%d", &ch);
printf("The ASCII value of %d is %c\n", ch, ch);
return 0;
}
T3.
#include <stdio.h>
int main(){
printf("\a");
printf("Startled by the sudden sound, Sally shouted.\n");
printf("\"By the Great Pumpkin, what was that?\"\n");
}
T4.
#include <stdio.h>
int main()
{
double x;
printf("Enter a floating-point value:");
scanf("%lf",&x);
printf("fixed-point notation: %f\n", x);
printf("exponential notation: %e\n", x);
printf("p notation: %A\n", x);//用大写的A表示十六进制,代替E表示科学计数法。
return 0;
}
T5.
#include <stdio.h>
int main()
{
double years;
printf("Enter your age in years: ");
scanf("%lf", &years);
printf("Your age is %lf and converted to seconds is %e seconds.\n", years, years *3.156e+7);
return 0;
}
T6.
#include <stdio.h>
int main() {
double water;
printf("Please enter the number of quarts of water: ");
scanf("%lf", &water);
double amount = water *950/3.0e-23;
printf("The number of water molecules is: %e", amount);
return 0;
}
T7.
#include <stdio.h>
int main()
{
float height;
printf("Enter your height in inches: ");
scanf("%f", &height);
printf("Your height in centimeters is: %.2f\n", height * 2.54);
return 0;
}
T8.
#include <stdio.h>
int main()
{
int cup;
printf("Enter the amount of cups you drank: ");
scanf("%d", &cup);
double oz = cup * 8;
double ladle = oz*2;
double teaspoon = ladle*3;
printf("You drank %.1f ounces of water.\n", oz);
printf("You used %.1f ladles.\n", ladle);
printf("You used %.1f teaspoons.\n", teaspoon);
return 0;
}