Ok i apologize in advance for my ignorance but i have just started learning c++ and my first program went off without a hitch now this one that im doing completely on my own is giving me some hiccups. The best i can tell is that im just having some problems compiling it through xcode or its something that i am not experienced enough yet to diagnose any help would be greatly appreciated.

#include <iostream>
#include <fstream>
#include <cstdlib>

using namespace std;

int main()
{
 const int LIMIT = 10000;
 int number = 2;
 while (number <= LIMIT) {
   int sumofDivisor = 0;
   int posDivisor = 1; 
   while (posDivisor <= number / 2)
     if (number % posDivisor == 0)
	   sumofDivisor = sumofDivisor + posDivisor;
	   if (number == sumofDivisor)
	     cout << number << "is perfect. \n";
	posDivisor ++;
	}
 number ++;
}

Well the first thing I see is you don't have your int main() function closed, try adding a } to the end of all that.

Cameron

Your program as posted compiles without error for me. using VC++ 2008 Express. Looks like a logic error though -- you need more brackets around that last while loop (lines 14-18).

The brackets are fine. Add "return 0;" at the end of the main.

ok so that fixed the problem of nothing being printed but i'm having trouble that it wont increase now it just says 2 is perfect then 2 is perfect

The brackets are fine. .

Apparently you didn't bother to read/understand the program. There are not enough brackets { and }.

First you have too many loops. You don't need that outer loop that starts on line 11. So delete lines 11 and 20.

line 14: replace number/2 with LIMIT.

put open bracket at line 15 and close at line 20.

Align the program indentions correctly so that you can see what's going on.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.