Vision and dreams are the blueprints of soul and achievements.
-Mohammed Ahmed F

Perfect number

Perfect number:

#include<stdio.h>
#include<conio.h>
int main()
{
  int n,i=1,sum=0;
  printf("Enter a number: ");
  scanf("%d",&n);
 
  while(i<n)
{
      if(n%i==0)
           sum=sum+i;
          i++;
  }
  if(sum==n)
      printf("%d is a perfect number",i);
  else
      printf("%d is not a perfect number",i);
  return 0;
getch();
}

Share this

Related Posts

Dear User,

Thank you for your comment. Hope you like this blog. Kindly share us on Social Media so others can be updated.

-Chief Administrative Officer.

Note: only a member of this blog may post a comment.