Here is the coding of C program to check perfect number using while loop

Before getting into the depth, we want to let you know what actually is Perfect number.

Perfect number is those numbers which divisor number’s sum are equal to that number, for more insight lets have a glance in one example.

E.g: 28 is perfect number ! Divisor of number 28 are : 1,2,4,7 & 14 Lets add all these divisor numbers : 1+2+4+7+14 = 28

Hence Sum of divisor of number 28 is equal to 28, that is why 28 is one of the example of perfect number.

Here is C program code to check perfect number using while loop:

int main()
     int i, num, sum=0;
printf("Enter any number to check perfect number: ");
scanf("%d", &num);

// Calculate sum of all proper divisors
for(i=1; i<num; i++)
    //If i is a divisor of num
    if(num%i == 0)
        sum += i;

//Check whether the sum of proper divisors is equal to num
if(sum == num)
    printf("%d is PERFECT NUMBER", num);
    printf("%d is NOT PERFECT NUMBER", num);
getch ();
return 0;

Please let us know your opinion

Click on a star to rate it!

Average rating 5 / 5. Vote count: 3

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Leave a Reply

Notify of
CIF: -
CP: 12140 Kathmandu (Nepal)
Tel: +9779823573469, +9779813987367

limitedscience6@gmail.com, Jivanmainali6@gmail.com

"Qualitative ,Informative and useful knowledge"
error: Content is protected !!