Find the sum of all numbers from 0 to 200

Set two integer variables i and sum
i to represent numbers from 0 to 200, which are used as a loop
sum to store the sum of the two numbers obtained each time, and finally output the value of sum

#include<stdio.h>
int main()
{
	int sum = 0;
	for(int i = 0;i <= 200;i++)
	{
		sum += i;
	}	
	printf("%d\n",sum);
	return 0;
}

Guess you like

Origin blog.csdn.net/weixin_45824959/article/details/104056790