Question: I'm trying to write a program perfectNumber.c that asks user repeatedly for a non-negative integer, and stops when the number is zero. For each positive

I'm trying to write a program perfectNumber.c that asks user repeatedly for a non-negative integer, and stops when the number is zero. For each positive integer entered, your program is to check whether it is a perfect number or not.

Your program should have a function is_perfect(int) that returns 1 if the argument is a perfect number, or 0 otherwise.

Whats wrong with my code?

I'm trying to write a program perfectNumber.c that asks user repeatedly for

/** k x 5 #include # include int is perfect (int); 7 int main (void) { int num; printf("Enter number: ") scanf ("%d" , &num) ; if (is perfect (num)1) ( 10 12 13 printf("%d is a perfect number. ",num); 15 16 17 18 19 L 20 int IS perfect (int num) { 21 (is perfect (num) printf("%d is not a perfect number. ",num); if { return 0; int perfect_number; int pp 1; perfectnumber-(pow2, (pp-1))) * ( (pow (, pp))-1): while (pp >= 1) { 23 25 26 27 28 29 30 31 32 if (perfect_number num) break; return 0; else if (perfect numbernum) [ return 1; 3 4 35 36 37 L return is perfect (num)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!