[SOLVED] C program to fill an integer array of size 5

20.00 $

Category:

Description

5/5 - (1 vote)

Write a C program to fill an integer array of size 5 and print how many perfect numbers are in this array. A perfect number is defined as a positive integer that is equal to the sum of its proper divisors.

– Declare an integer array of size 5

– Fill the array with positive numbers only

– Write a function called (isPerfect) to detect if an integer is a perfect number or not. The function takes an integer n as input and returns the same number if it is perfect, or -1 if it is not perfect.

– Use the function (isPerfect) to write the code to loop through the array and counts the perfect numbers only. Then print the count.

Example of a perfect number:

6 = 1 + 2 + 3

28 = 1 + 2 + 4 + 7 + 14