The first experiment Report of C language ———— the content of PTA experiment 1.2.3

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.