Computer Science, asked by Bittu808, 1 year ago

write a program to check whether a no is perfect number or not.

Answers

Answered by golu46
0
#include<stdio.h>
#include<conio.h>
void main()
{
int number , rem,sum=0, i ;
clrscr();
printf("enter a number\n");
scanf("%d", &number);
for ( i=1 ; i<=(number - 1); i++)
{
rem = number % i;
if ( rem ==0)
{
sum= sum + i;
}
}
if ( sum== number)
printf("number is perfect number\n");
else
printf("number is not a perfect number");
getch();
}
Similar questions