Computer Science, asked by julie8604, 2 months ago

Write a program that accepts a positive integer from keyboard and check if it is a perfect number.
A perfect number, p, is a positive integer that equals the sum of its divisors, excluding p itself. For example, 6 is a perfect number because the divisors of 6 (1, 2, and 3) sum to 6. There are actually only three perfect numbers less than 1000, and they are 6, 28 and 496.

Answers

Answered by 2009nagaganesh
1

Answer:

Here You GO

Explanation:

#include <stdio.h>

int main() { int num,loop;

int sum; printf ( "Enter an integer number: " );

scanf ( "%d" ,&num);

sum=0; for (loop=1; loop<num;loop++)

{ if (num%loop==0) sum+=loop;

} if (sum==num)

printf ( "%d is a perfect number." ,num); else. printf ( "%d is not a perfect number." ,num);

Similar questions