The following code shows how to Find Whether a Number is a Perfect Number or Not in C.

// To Find Whether a number is a perfect number or not

#include <stdio.h>

int main()
{
    int mynum, factorsum=0, i;
    printf("Enter a number: ");
    scanf("%d", &mynum);
    for(i=1;i<=mynum/2;i++)
    {
        if(mynum%i==0)
        {
            factorsum+=i;
        }
    }
    if(factorsum==mynum)
    {
        printf("%d is a perfect number!", mynum);
    }
    else
    {
        printf("%d is not a perfect number!", mynum);        
    }
    return 0;
}

Output

The Output of the Program to Find Whether a Number is a Perfect Number or Not in C
The Output of the Program to Find Whether a Number is a Perfect Number or Not in C

Further Reading

50+ C Programming Interview Questions and Answers

C Program to Find Factorial of a Number