Perfect Number Program in C

This Perfect Number Program in C post provides implementation program that checks whether the given input number is Perfect Number or Not using C language syntax. This post is also providing the flow chart for Perfect Number Program to make you more clear the logic.


Definition: Sum of factors of given number except itself is equal to the same number

#include<stdio.h>
void main()
{
int n , i, sum=0 ;
printf(“Enter an integer : “);
scanf(“%d”, &n);
for(i=1 ; i<n ; i++)
{
if(n%i==0)
{
sum = sum+i ;
}
}
if(n==sum)
printf(“Perfect Number”);
else
printf(“Not a Perfect Number”);
}


FlowChart :

Perfect Number program FlowChart

Perfect Number FlowChart

Share this