• 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