(编译环境 Microsoft Visual Studio 2019)
1.
/*1.*/
#include<stdio.h>
#include<limits.h>
int main(void)
{
int i_toobig= 3147483647;
float f_toobig = 3.4e38f * 100.0f;
float f_toosmall = 3.5e-40f;
printf("toobig int : %d\n", i_toobig);
printf("toobig float : %f\n", f_toobig);
printf("toosmall float : %f\n", f_toosmall);
return 0;
}
2.
/*2.*/
#include<stdio.h>
int main(void)
{
char character;
printf("Please enter an ASCII code value.\n");
scanf_s("%hhd", &character);
printf("character: %c\n", character);
return 0;
}
3.
/*3.*/
#include<stdio.h>
int main(void)
{
printf("\aStartled by the sudden sound,Sally shouted,\n");
printf("\"By the Great Pumpkin,what was that!\"\n");
return 0;
}
4.
/*4.*/
#include<stdio.h>
int main(void)
{
float value;
printf("Enter a floating-point value: ");;
scanf_s("%f", &value);
printf("fixed-point notationn: %.6f\n",value);
printf("exponential notation: %.6e\n",value);
printf("p notation: %.2a\n",value);
return 0;
}
5.
/*5.*/
#include<stdio.h>
int main(void)
{
unsigned short age;
float seconds;
printf("Pleasee enter your age.\n");
scanf_s("%hu", &age);
seconds = age * 3.156e7f;
printf("seconds=%e\n", seconds);
return 0;
}
6.
/*6.*/
#include<stdio.h>
int main(void)
{
float quarter, number;
printf("Please enter the quarter number of water.\n");
scanf_s("%f", &quarter);
number = (quarter * 950) / 3.0e-23f;
printf("%f quarter of water has %e water molecules.\n", quarter, number);
return 0;
}
7.
/*7.*/
#include<stdio.h>
int main(void)
{
float inch;
printf("Please enter your height in inch.\n");
scanf_s("%f", &inch);
printf("Your height is %.2f in centimeter.\n", inch * 25.4f);
return 0;
}
8.
/*8.*/
#include<stdio.h>
int main(void)
{
float cups;
printf("Please enter the cups.\n");
scanf_s("%f", &cups);
printf("pint: %.2f\n", cups / 2);
printf("ounce: %.2f\n", cups * 8);
printf("spoon: %.2f\n", cups * 2);
printf("teaspoon: %.2f\n", cups * 3);
return 0;
}