WAP to find the perfect number in c
#include<stdio.h>
void main()
{
int i=1,n,sum=0;
printf("enter a number \n");
scanf("%d",&n);
while(i<n)
{
if(n%i==0)
sum=sum+i;
i++;
}
if(sum==n)
{
printf("perfect number=%d",i);
}
else
{
printf("not perfect number=%d",i);
}
getch();
}
No comments:
Post a Comment