Friday, September 12, 2008

PERFECT NUMBER- c programming language



void main()
{
int n,i=1,sum=0;
clrscr();
printf("\nEnter a number:-");
scanf("%d",&n);
while(i
{
if(n%i==0)
sum=sum+i;
i++;
}
if(sum==n)
printf("\nThe no %d is a perfect number",i);
else
printf("\nThe no %d is not a perfect number",i);
getch();
}

No comments:

Post a Comment

Thanks to given comments.......

My Blog List