#include <stdio.h>

main() {
  int n, i, sum = 0;
  printf("Enter a Number:\n");
  scanf("%d", & n);

  for (i = 1; i < n; i++) {
    if (n % i == 0) {
      sum = sum + i;
    }
  }

  if (sum == n) {
    printf("%d is a perfect number", n);
  } else {
    printf("%d is not a perfect number", n);
  }
}
     
           
Note: Need to be arranged in compiler after copied
   

 OutPut:

Enter a Number: 28 28 is a perfect number