954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

perfect numbers

When i run the program it shows the first line then blank i dont know whats wrong!

#include <cstdio>
#include "simpio.h"
#include "strlib.h"

int main()
{
	int i, d, t;

	printf("This program generates all perfect numbers from 1 to 100.\n");
	t = 0;
	for (i=1; i<=100; i++)
	{
		for (d=1; d<i; i++)
			{
				if(i%d==0)
				{
					t = d + t;
				}
			else;
			}
		if(t == i)
		{
			printf("%d\n",i);
		}
		else;
		t = 0;
	}
  system("pause");
}
plike922
Light Poster
39 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

if i=1 and d=1 would dexecute? What do you say?

Would if(t == i) have a chance of being execute without t being initialized to any value?

Aia
Nearly a Posting Maven
2,392 posts since Dec 2006
Reputation Points: 2,224
Solved Threads: 218
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You