Awhole number is said to be a perfect number if its factors,including 1 but not
ID: 3614972 • Letter: A
Question
Awhole number is said to be a perfect number if its factors,including 1 but not the number itself, sum to the number. Write a program that reads in a positive integer and determineswhether it is a perfect number. If the number is perfect, theprogram should also display its factors on the screen. Definea function perfect to determine whether a number is perfect, and afunction printFactors to print the factors, including 1 but not thenumber itself, of a given number on the screen.
Example:
Thisprogram determines whether a number is a perfect number.
Enter a positive integer: 6
6 isa perfect number.
Factors of 6: 1 2 3
Explanation / Answer
please rate - thanks #include #include void factors(int); int perfect(int); int main() {int num; printf("Enter a number: "); scanf("%d",&num); if(perfect(num)==1) {printf("%d is a perfectnumber ",num); printf("Factors of%d: ",num); factors(num); } else printf("%d is nota perfect number ",num); getch(); return 0; } void factors(int n) {int i; for(i=1;iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.