/*输出华氏-摄氏温度转换表,华氏温度取值【lower,upper】,每次增加1f*/ #include<stdio.h> int main(void) { int fahr,lower,upper; double celsius; printf("Enter lower:"); scanf("%d",&lower); printf("Enter upper:"); scanf("%d",&upper); printf("fahr celsius "); for(fahr=lower;fahr<=upper;fahr++){ celsius=(5.0/9.0)*(fahr-32); printf("%d%6.1f ",fahr,celsius); } return 0; }
/*计算存款的本息*/ #include<stdio.h> #include<math.h> int main(void) { int money,year; double rate,sum; printf("Enter money:"); scanf("%d",&money); printf("Enter year:"); scanf("%d",&year); printf("Enter rate:"); scanf("%lf",&rate); sum=money*pow(1+rate,year); printf("sum=%.2f ",sum); return 0; }