How to Check Whether Number is Perfect Or Not using C

C Program to Check Whether Number is Perfect Or Not

Hello there, in this tutorial we will learn to check whether number is perfect or not using c programming ?

Also Use : Perfect Number Checker Tool

What Is Perfect Number :

A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself.

#include <stdio.h>

int main() {
   int num, i = 1, sum = 0;

   printf("Enter a number: ");
   scanf("%d", &num);

   while (i < num) {
      if (num % i == 0) {
         sum = sum + i;

   if (sum == num)
      printf("%d is a Perfect Number", i);
      printf("%d is Non Perfect Number", i);

   return 0;
Also Read : Write C program to Check Whether a Number is Positive or Negative ?

Output :

Enter a number: 3
3 is Non Perfect Number