Chapter 2: Answers to After-Class Exercises


1. Multiple choice questions

1—5 DABDD
6—10 DAAAB
11—13 BCD

Two, programming questions

1. The formula for converting Huashi temperature to Celsius is: C=5/9(F-32)

#include<stdio.h>
int main()
{
    
    
	double F,C;
	printf("请输入华氏度");
	scanf("%lf",&F);
	C=5.00/9*(F-32);
	printf("摄氏度=%0.2lf\n",C);
	return 0;
} 

2. Write a program, enter an integer number of minutes from the keyboard, and convert it into hours and minutes

#include<stdio.h>
int main(){
    
    
	int a=0;
	int h=0,m=0;
	printf("输入一个整型的时间");
	scanf("%d",&a);
	h=a/60;
	m=a%60;
	printf("%d:%d",h,m);
	return 0;
} 

If you have any questions, you can leave a message in the comment area

Guess you like

Origin blog.csdn.net/buxiangquaa/article/details/114537221
Recommended