this is mostly personal preference, but I suggest [tt] over code tags
[tt] sets the font to a monospaced font, code doesn't. plus it's just prettier
#include <stdio.h>
int main(void) {
int itsum; /* Used to mark the iteration at which the sum loop is at */
double sum, /* The sum of the fractions */
d; /* The denominator */
for (d = 2; d <= 30; d++) {
sum = 0;
itsum = 1;
while (itsum <= d) {
sum = sum + (1 / d);
itsum++;
}
if (sum - 1 < 0.000000000000001 && sum - 1 > -0.000000000000001)
printf("Adding %lf 1/%lf's gives a result equal to 1\n", d, d);
else if (sum < 1)
printf("Adding %lf 1/%lf's gives a result less than 1\n", d, d);
else
printf("Adding %lf 1/%lf's gives a result greater than 1\n", d, d);
}
return 0;
}changes (at least, the ones I remember), from top to bottom:
changed indentation in the first three lines of
main(), so that the comments line up and
d lines up with
sumin the for loop, uh, thing, the bit between the parentheses, I added some spaces. aaand changed "
d < 31" to "
d <= 30" because it's more clear. out of all of my own changes that's probably the only one that I think really matters
I added zsno's correction (probably never would've figured that out myself)
also I removed the spaces before the apostrophes in the strings you're printing. idk if you just didn't know that would work, but it wasn't very attractive the way that it was before. and even now it's still grammatically off but whatever
I think the last thing is removing the extra blank lines before the closing brackets
most of it was cosmetic. but I do think the for loop condition is genuinely better this way
in marginally related news

why does that happen when I press the close button on the console window that was running it, as opposed to just pressing "any key to continue"?
when I just press spacebar it ends normally, with 0, but when I use the exit button it doesn't? in either case, the program itself ends normally, which is shown in the console window

it's just... like, the console window itself that seems to cause the problem. if it matters, and I'm sure it does, I'm using code::blocks
it doesn't cause any problems or anything, it's just weird. it's always like that, not only with this particular code