## ### Tel: +9779823573469, +9779813987367

limitedscience6@gmail.com, Jivanmainali6@gmail.com

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:

``````#include<stdio.h>
#include<conio.h>
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);
}
else
{
printf("%d is NOT PERFECT NUMBER", num);
}
getch ();
return 0;
}``````
Limitedscience
CIF: -
Https://www.limitedscience.com
CP: 12140 Kathmandu (Nepal)
Tel: +9779823573469, +9779813987367

limitedscience6@gmail.com, Jivanmainali6@gmail.com error: Content is protected !!