0

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");
}
2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Aia
0

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

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.