01 #include<stdio.h>

02

03 int main()

04 {

05 int n,i=1,sum=0;

06

07 printf("Enter a number:");

08 scanf("%d",&n);

09 while(i<n)

10 {

11 if(n%i==0)

12 sum=sum+i;

13 i++;

14 }

15 if(sum==n)

16 printf("%d is a perfect number",i);

17 else

18 printf("%d is not a perfect number",i);

19

20 return 0;

21 }

OUTPUT :

(1st Run )

Enter a number : 6

6 is a perfect number

(2nd Run )

Enter a number : 8

8 is not a perfect number

6