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