Work report > Experiment report

C language programming experiment report


The experiment name calculates the sum of the 10 largest prime numbers within 1000.
1. Proficient in the if, if...else, if...else if statement and witch statement format and usage methods, master the nesting relationship and matching principle in the if statement, and use the if statement and the switch statement to implement the branch selection structure.

2, proficient in the while statement, do...while statement and for statement format and use method, master the loop process of the three loop control statements and the nesting of the loop structure, and use the loop statement to realize the loop structure.

3. Master simple and commonly used algorithms and experience the programming skills of various algorithms in the programming process. Learn more about debugging programs and master grammar and logic errors.

The experimental content calculates and outputs the maximum 10 prime numbers within 1000 and their sum.

Claim:

Add the necessary comments inside the program.
Since even numbers are not prime numbers, the processing of even numbers can be ignored.
Although the number of primes within 1000 is more than 10, it is necessary to treat 10 primes within 1000.
The output form is: prime number 1 + prime number 2+ prime number 3 + ... + prime number 10 = sum value.
Algorithm description flow chart
Main function:


Judging the prime number:

Source program
#include

#include

Int sushu/* Function for judging prime numbers*/

{

Int t,i;

t=sqrt;

For

If/* If it is not a prime number, return 0 */

Return 0;

Return n;/* If it is a prime number, return that number*/

}


Void main

{

Int i,j=0,n,m=0,a[1000],x;

/*clrscr;*/

Printf;

Scanf;

Processing if/* x=2*/

Printf;

Else if /* x is processed outside the range of 1 to 1000 */

Printf;

Else

{

When if/* x is even, turn x into an odd number*/

X--;

When for/* x is an odd number, do a function calculation */

{

n=sushu; /* Make a function call to determine the prime number */


If/* handles prime numbers*/

{

a[j]=n;/* store the prime numbers from large to small in the array a[ ]*/

j++;

If

m+=n; /* Count the sum of the top 10 prime numbers*/

}

}

If/* When the number of prime numbers is less than 10, the result is output */

{

For;

Printf;

}

Printf;

Printf;

}

Else for/* When the number of prime numbers is greater than or equal to 10, the result is output */

{

n=a[i];

Printf;

If

Printf;

Else

{

Printf;

Printf;

}

}

}

}

The test data is input into the 1000, 100, and 10 tests.

Problems and solutions to the operation results When the number of prime numbers is less than 10, the processing is not perfect enough, and the consideration is not comprehensive enough. The treatment of "+2" is too reluctant.
The program is too large, not concise, and there is too much useless text.
Learning patience and carelessness, such as scanf; "&" often forget.
The programming idea is not divergent. For example, how to judge the prime number can only come up with two ways; in the future study, more brains should be used and comprehensively applied.
Basic skills are not enough, such as clear screen clrscr and other functions are not good, sometimes the same problem has been repeatedly committed, bringing great trouble to the experimental class teacher. This shows that my knowledge is not wide enough, there are many useful books in the book that do not require the exam, and the content is not well learned. Even after the end of the C language course, you should look at the relevant things and practice on the machine to truly improve yourself.
Physical experiment report, chemical experiment report, biological experiment report, experimental report format, experimental report template knowledge is not extensive enough, such as VC++6.0 and other programs, it will not be used for a while; it shows that my computer level is not enough, self-study ability is not enough . The things that have been mastered are still not good enough.
Experimental experience Through this C language experiment, I have a certain experience of this computer programming language between human and non-human. In the meantime, I was happy, depressed, helpless, and stunned... With the success of the experiment and the success of the experimental report, a little bit of pride is unforgettable. I would like to thank Professor Gao Kening for his high standards and strict requirements. Thanks to the patience and guidance of the teachers in the lab class, and to the bits and pieces I have experienced in the experiment... With the deepening of the study, I found that there are many things deep and deep. Waiting for me to dig. I will work harder on the C language.

recommended article

popular articles