computing-fundamentals
C programs and question bank.
Wednesday, October 27, 2010
perfect num-c
void main()
{
int n,i=1,sum=0;
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
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment