Program to check whether the given no is Perfect number or not

#include<stdio.h>
#include<conio.h>
main()
{
int n, i , c = 0;
printf (“enter a number”);
scanf (“ %d”, & n);
for (i=1; i < = n/2;  i++)
{
  If(n%i==0)
  c=c+i;
}
if (c==n)
printf (“perfect number”);
else
printf (“not a perfect number”);
getch();
}

Out Put:

Enter a no 89
Not a perfect number

Enter a no 6

Perfect number

Related

C Programs 7184033002382422729

Post a Comment

emo-but-icon

item