First, the PTA experimental work 1. Temperature conversion
The subject requires a program to calculate the Celsius temperature of Fahrenheit 100°f. Calculation formula:C=5x(F? 32)/9, in the form: C is thetemperature of Celsius,F for Fahrenheit, the output data requirements for the integer type.
1. Experiment Code
2. Design Ideas
- (1) Define Fahr,celsius to store Fahrenheit temperature and Celsius temperature data separately;
- (2) Calculation using the given formula;
- (3) Output results.
3. Problems encountered during commissioning and solutions
The output format is not noticed and causes an error.
Topic 2. Ladder Tariff
In order to promote the residents to save electricity, a provincial power company to carry out "ladder price", the installation of a table of the residents of the electricity price is divided into two "ladder": the monthly electricity consumption of 50-kilowatt (including 50-kilowatt hours) within the price of 0.53 yuan/kwh; more than 50-kilowatt, excess power consumption, electricity price raised 0.05 yuan/ Kwh. Please write a program to calculate the electricity bill.
1. Experiment Code
2. Design Ideas
- (1) Define floating-point variable x,cost;
- (2) using if structure to obtain the answer, output.
- 3. Problems encountered during commissioning and solutions
- It was not noticed at first to use a floating-point variable , with an int to define X and cost, resulting in an error. Later access to textbooks, to be resolved.
- Topic 3. Output Fahrenheit-Celsius temperature conversion table
- 1. Experiment Code
-
- 2. Design Ideas
- (1) Define int and double type variables, use if mechanism to meet the topic requirements;
- (2) Use for loop, get answer, output .
- 3. Problems encountered during commissioning and solutions
- For loop using unskilled, in parentheses; causes multiple errors. Read the textbook and get it resolved.
The first experiment Report of C language ———— the content of PTA experiment 1.2.3