C Primer Plus 第三章
编程练习5:
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
int age;
int second;
int sum;
second = 3.156e7;
printf("Please enter your age:\n");
scanf("%d", &age);
sum = age * second;
printf("Your age is equal to:");
printf("%dseconds\n", sum);
return 0;
}
编程练习6:
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
double w_m=3.0e-23;
float w_k;
float w_e;
float w_a;
printf("Please enter w_k num:");
scanf("%f", &w_k);
w_e = 950 * w_k;
w_a = w_e / w_m;
printf("w_k equal to:%fw_m",w_a);
return 0;
}
编程练习7:
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
double inch;
printf("Please enter your height:\n");
scanf("%lf", &inch);
double tall;
tall = inch * 2.54;
printf("Your height is %lfcm\n",tall);
return 0;
}
编程练习8:
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
printf("Please enter caps:\n");
double pint;
double caps;
scanf("%lf", &caps);
double ance;
double spoon;
pint = caps* 0.500;
ance = caps* 8.00;
spoon = caps* 625.00;
printf("caps equal to %lf pint\n", pint);
printf("caps equal to %lf ance\n", ance);
printf("caps equal to %lf spoon\n", spoon);
return 0;
}