Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C++ assist

Name: C++ Noob 2010-09-23 23:58

Ok so I am learning C++ and I suck.

Trying to add 1/1 + 1/2 + ... + 1/99 + 1/100

The problem is I can't get the denominator to increase as I attempt to add them.
Anyone care to point out my most likely obvious mistake?

This is what I have


#include <iostream>

using namespace std;

void main ()
    {
    const    long    MaxNum (100);
    double    i;
    double    Sum;
    double    x;
    for (x = 1, i = 1/1, Sum = 0; x <= MaxNum; x++)
        Sum += i;
    cout << "Sum is " << Sum << endl;
}

Name: Anonymous 2010-09-24 12:06

>>13
this is copypasta. i can tell from having written this text last year sometime

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List