#include <stdio.h> int main(void) { int i; double total = 0.0, a = 1.0; for(i = 0; i < 100; i++) { total += 1 / a; a = -1 * a; if(a < 0) a--; else a++; } printf("1 - 1/2 + 1/3 - ... + 1/99 - 1/100 = %f\n", total); return 0; }