计算给定整数的平方和

#include <stdio.h>

int main(void){
  int sum, count, max_count;
  sum = 0;
  count = 1;

  printf("How many squares would you like to sum? ");
  scanf("%d", &max_count);

  while (count <= max_count){
    sum = sum + count * count;
    count++;
  }
  printf("The sum of the first %d squares is: %d/n", max_count, sum);

  return 0;
}

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/266549.html

(0)
上一篇 2022年6月7日
下一篇 2022年6月7日

相关推荐

发表回复

登录后才能评论