C program to check whether given number is Perfect number or not

</code>: Check number is perfect number or not
// C program to check whether given number is Perfect number or not
 
#include <stdio.h>
 
int main()
{
    int j, number, temp = 0;
 
    // get input a from user 
    printf("Enter integer number to check perfect number :");
    scanf("%d", &number);
 
    
    for(j=1; j<number; j++)
    {
        // if mode of number%j equal to zero then print it
        if(number%j==0)
        {
            temp = temp + j;
        }
    }
 
    // Check temp is equal to number then print number 
    if(temp == number)
    {
        printf("\n%d is a Perfect number", number);
    }
    else
    {
        printf("\n%d is not a Perfect number", number);
    }
 
    return 0;
}
 
output:

Enter integer number to check perfect number :28

28 is a Perfect number

LANGUAGE