01: #include <stdio.h> 02: 03: int main(void){ 04: int i, imax; 05: int sum; 06: 07: printf("1からいくつまでの2乗和を計算しますか?\t"); 08: scanf("%d", &imax); 09: 10: sum = 0; 11: i = 1; 12: 13: do{ 14: sum += i*i; 15: i++; 16: }while(i<=imax); 17: 18: 19: printf("sum = %d\n", sum); 20: 21: return 0; 22: }