Check perfect number

Perfect number is a number which is equal to sum of its divisor.For eg,divisors of 6 are 1,2 and 3.The sum of these divisors is 6.So 6 is called as perfect number.

Here input is accepted by variable n.Divisor d is used whose initial value is 1 and variable sum is used whose initial value is 0.The divisor d divides the variable n and then adds itself to variable sum if the remainder is 0.The divisor is then incremented by 1.This process continous until divisor d is less than or equal to n/2.At the end,if the variable sum is equivalent to variable n,then the variable n is perfect number. Else it is not a perfect number.

#include < stdio.h >
#include < conio.h > 

void main()
{
	int n,d,sum;
	
	clrscr();
	printf("\n Enter n : ");
	scanf("%d",&n);
	sum = 0;
	
	d = 1;
	while ( d<= n/2)
	{
		if ( n % d == 0 )
		{
			sum = sum + d;
		}
		d++;
	} // while
	if ( sum == n )
		printf("\n %d is perfect",n);
	else
		printf("\n %d is not perfect",n);
} // main