Q.) Find out the perfect number using C- program .
Sol)
#include<stdio.h>
#include<conio.h>
int main( )
{
int n, i=1, sum=0;
printf("Enter a Number : ") ;
scanf("%d",&n) ;
while(i<n)
{
if(n%i==0)
{ sum=sum+i ; }
i++ ;
}
if(sum==n)
printf("\n %d is a perfect number", i) ;
else
printf("\n %d is not a perfect number", i) ;
return 0;
}
:: OUTPUT ::
Enter a Number : 6
6 is perfect number