C Language Programming 7th homework

Source: Internet
Author: User

First, the main content of this lesson:

To calculate the cylinder volume as an example, by defining the function of the volume calculation function and the example of the main function call, the general form of the function definition is drawn: The function body is added to the first part of the function, and the result is returned by the return statement at the end. The SectionTo focus on two points:

(1) Formal parameters, arguments and parameter transfer. Parameters can be represented only by variables, in functions, and arguments may be variables, constants, or expressions, in the keynote function. The actual participation parameters are consistent in number and type. When a parameter is passed, the argument passes the variable, the value of the constant, or the result value of the expression to the parameter.

(2) Function definition header and declaration. Similar in form, the purpose of the function declaration is to explain the type and parameters of the function, so as to ensure that the function calls are judged correctly when the program compiles, and the declaration position is usually preceded by the main function. The first part of the function definition is defined by the function body, which is composed of a function definition.

second, the experimental content: (70 points)

1. Use the function to calculate the value of the segment function: Enter x to calculate and output the value of the Segment function f (x). Requires defining and invoking a function sign (x) to implement the Piecewise function. Try to write the appropriate program.

2. Use the function to find odd numbers and: Enter a batch of positive integers (with 0 or negative as the end flag) to find the odd and. It is required to define and invoke the parity of the number of functions even (n), which returns 1 if n is even, otherwise returns 0. Try to write the appropriate program.

3. Use the function to calculate the distance between two points: any two point coordinates (x1, y1) and (x2, y2) of the given plane, and the distance between the two points (Reserved 2 decimal places). Requires defining and calling functions Dist (x1, y1, x2, y2) to calculate the distance between two points. Try to write the appropriate program.

4. Use the function to calculate the number of elements and sum: Enter 2 positive integers m and n (1<=m,n<=500), statistic and output the number of primes between M and N, and the sums of these primes. A prime number is a positive integer divisible only by 1 and itself, 1 is not a prime, and 2 is a prime number. The request defines and calls the function prime (m) to determine if M is a prime number, and returns 1 if M is a prime number, otherwise returns 0.

5. Use the function to find the maximum value: Enter 2 numbers and output the larger number. Requires the definition and invocation of the function Max (A, A, a, b) to find and return the larger number in a and. Try to write the appropriate program.

Third, the experimental requirements:

1. Deadline:2016-11-3 23:00pm of the job

2. Upload the code of the experiment content to the https://coding.net/website. (70 points)

3. Write an essay, divided into four parts: (total 30 points)

Write this lesson to learn the knowledge and experience, the length of study, the learning process encountered problems, problem solving methods and doubts and so on.

The format of the essay is as follows:

topic: Experiment seven--function definition and invocation summary

1. The learning Points of this lesson: (5 points)

(1) .....

(2) .....

...........

2. Problems encountered during the experiment and solutions: (10 points)

(1)

(2)

.......

3. Experimental experience and summary of this chapter (5 points)

.........

Four, prepare for the next lesson:

Preview the textbook example 5-5 program, realize that the function definition in this example is different from the previous function definition, further grasp the idea of double circulation and realize the thought of structured program design. Check in the lab before class (10)

Five, the operation evaluation method:

Total score 100: Among them, the coding program submits 70 points (according to the code steps, the format, the annotation, the structure correctness assigns the discretion), the blog writes 30 points, the delay day deduction 10 points, until the deduction 100 points.

Six, additional questions: (The completion of this additional problem can make up for the 6th time not scored, I hope we can fill up in time, each question 20 points, a total of 80 points, upload coding.net on, write a blog summary 20 points)

1. Ask for the value of E: enter 1 positive integer n, calculate the value of E (reserved 8 decimal places), require the use of nested loops.

2. Change coins. Convert a small change (greater than 8 cents, less than $1, to a precise score) into 5, 2 and 1 coins, each with at least one coin. Enter the amount, ask how many different ways? For each type of exchange, the number of coins and the total number of coins are output. Try to write the appropriate program.

3. Find the number of digits and the sum of your numbers: Enter an integer to find the number of digits and the sum of your numbers. For example, the number of digits in 123 is 3, and the sum of the figures is 6.

4. A+AA+AAA+AA...A: Enter two positive integers a and n for the sum of a + AA + AAA + AA...A (n a). Try to write the appropriate program.

C Language Programming 7th homework

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.