The first experiment Report of C language

Source: Internet
Author: User

• Experimental topics, design ideas, implementation methods

Experiment topic one; calculate piecewise function and loop new (Calculate Piecewise function (3)) for a problem of mathematical transformation, we should follow the requirements given by the topic, then analyze what kind of statement to use to achieve, further assignment test expression, and finally check whether it is correct.

Experiment topic two; calculation of piecewise function and cyclic new (integer arithmetic) the arithmetic of mathematical subtraction to be expressed in C language, we can use the assignment to try to express, check whether it is correct.

Experiment topic three; calculate the piecewise function and the loop new (the first n of a sequence of n) set the loop variable, the loop class is represented by a for statement, the symbol of each item is represented by the variable flag, and the final test is correct.

Two • source program

Experiment one, the experiment topic, the design idea, the realization method

Experiment topic one; calculate piecewise function and loop new (Calculate Piecewise function (3)) for a problem of mathematical transformation, we should follow the requirements of the topic, and then analyze what kind of statement to use to achieve, further assignment test expression, the final check is correct.

Second, source program;

Experiment one;

{

Double x, y;

scanf ("%lf", &x);

if (x!=10) {y=x;

printf ("f (%.1lf) =%.1lf\n", x, y);

}

else{y=1/x; printf ("f (%.1lf) =%.1lf\n", x, y); }

Experiment two;
{
int A, B;
scanf ("%d%d", &a,&b);
printf ("%d +%d =%d\n", a,b,a+b);
printf ("%d-%d =%d\n", a,b,a-b);
printf ("%d *%d =%d\n", a,b,a*b);
printf ("%d/%d =%d\n", a,b,a/b);

Experiment Three;

int n,i,denominator;
Double sum,item,s;
scanf ("%d", &n);
S=0,denominator=1;
for (i=1;i<=n;i++) {
Item=1.0/denominator;
S=s+item;
denominator=denominator+1;
Sum=s;
}

printf ("sum =%.6lf\n", sum,s);

The problems encountered and the solutions, experience

1. The problem is cumbersome, there are compile errors, format errors, and some of the correct problems.

2. The solution; When encountering an error, carefully check that each step is used correctly, also found in the code when the most important thing is careful, space and so on, the details are important.

3. For C language programming, is to convert a number of concepts into symbols, in order to facilitate the operation of the computer, at the same time do exercise we have to be careful and rigorous.

The first experiment Report of C language

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.