PERFECT NUMBER
Code :
#include<stdio.h>
int main()
{
int num, sum = 0, perf = 0;
printf("==================================\n");
printf("\t PERFECT NUMBER\n");
printf("==================================\n");
printf("Enter any number : ");
scanf("%d", &num);
printf("\n");
for(int i=1; i<num; i++)
{
if(num%i == 0)
{
sum += i;
}
}
if(sum == num)
{
printf("%d is a Perfect number\n", num);
}
else
{
printf("%d is Not a Perfect number\n", num);
}
printf("----------------------------------\n");
return 0;
}
Come again Learn again !
« iCodeBuzz »
No comments:
Post a Comment