Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to realize summation program code with C language programming?
How to realize summation program code with C language programming?
1. First, write # include < stdio.h & gt? Main (), as shown in the figure below.

2. After that, you need to define several variables, one for storing sum and the other from 1 to 100, as shown in the following figure.

3. After writing the for loop, first assign the value to I as 1, where if it is required to be within 200, the number 100 is changed to 200.

4. Then write the content of the for loop, sum = sum+i; Add the value of each I to the sum.

5. Finally, output it and write an output statement to output it. Sum is being reshaped, so %d is used, as shown in the figure below.