C Language Programming second job

Source: Internet
Author: User

(a) Correct the wrong question

1. Output with box text: Output The following 3 lines of information on the screen.

Error message 1:

Error cause 1:stdio Error
Correction method: Change Sitdo to Stdio

Error message 2:

Error cause 2: line 5th statement without semicolon

Correction method: Add a semicolon at the end of the statement

Error message 3:

Error reason 3: line 6th less one quote in printf

Correction Method: Enter quotation marks

Error message 4:

Error cause 4:mian writing error

Correction method: Change Mian to Main

2. Calculate the square of a number x for Y: Outputs the values of x and Y, respectively, as "y = xx" and "xx = y". Note Do not delete any comments in the source program.
Input output sample (assuming the value of X is 3)

Error message 1:

The cause of the error is less 1:stdio. h

Correction Method 1: Input. h

Error message 2:

Error cause 2: Comment Usage Error

Correction method: Add after Output */

Error message 3:

Error cause 3:printf output variable has only one

Correction Method 3: Should output three variables for y,x,x

Error message 4: Ibid. error message 3, add the second printf output variable to complete

Error message 5:

Error cause 5: No value assigned to X

Correction method: Assigning values after initialization

Error message 6:

Error cause 6: Output format error

Correction Method 6: Output \ n in printf

Ii. Summary of the study
1. (1)

(2)

(3)

(4)

2. In the C language, in the header file Limits.h, there is a macro definition of the maximum and minimum values for various basic data types. For example, the maximum value of type int is int_max and the minimum value is int_min. Run the following procedure to see what the results are?

Modify the program, output i+1, what is the result? Why?

Maximum overflow!

Modify the program output j-1, what is the result? Why?

Overflow

3. Run the following program, enter 100 144 64, and see what the results are? Why?

Binary error,%0 is octal,%x is hexadecimal

4: summary

In writing procedures is must be careful! Train yourself to have rigorous thinking!

III) Experimental Summary
1. Find integer mean
(1) Title
The subject asks to write a program that calculates the 4 integers and the average. The title guarantees that both the input and output are within the integral type range.
(2) Flowchart

(3) Source code

(4) test data and operating results

(5) Experimental analysis

Issue 1: Output format error

Cause: The output average retains one decimal place, not carefully examining

Workaround: Use%.1f to preserve its accuracy when outputting

3. Is it too fat?
(1) Title
It is said that a person's standard weight should be his height (in centimeters) minus 100, and then multiplied by 0.9 of the number of kilograms. The known Jin is twice times the kilogram. Given a person's height, would you please calculate what the standard weight should be?
(2) Flowchart

(3) Source code

(4) test data and operating results

5. Calculate the distance of the object's free fall
(1) Title
An object falls free from the height of 100 meters. Write a program that asks for the vertical distance it drops within the first 3 seconds. Set the gravitational acceleration to 10 m/s 2.
(2) Flowchart

(3) Source code

(4) test data and operating results

9. Three-digit number in reverse order
(1) Title
The program reads a positive 3-digit number each time, and then outputs the digits in reverse order. Note: When the input number contains the end of 0 o'clock, the output should not have a leading 0. For example, enter 700 and the output should be 7.
(2) Flowchart

(3) Source code

(4) test data and operating results

(d) PTA Submission List
Order structure (i) Submit list

Sequential structure (ii) submission list

C Language Programming second job

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.