Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Thread Contributor: Ravishankar ChavareHow to create a program to find a perfect number
#1
Code:
#include <stdio.h>
int main()

{
int number, reminder, sum = 0, i;

 

printf("Enter a Number\n");

scanf("%d", &number);

for (i = 1; i <= (number - 1); i++)

{

reminder = number % i;

    if (reminder == 0)

{

sum = sum + i;

}

}

if (sum == number)

printf("Entered Number is perfect number");

else

printf("Entered Number is not a perfect number");

return 0;

}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)