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: i = 1; 12: 13: while(i<=imax){ 14: sum += i; 15: i+=2; 16: } 17: 18: 19: printf("sum = %d\n", sum); 20: 21: return 0; 22: }