# Case study :d

Discussion in 'C' started by Luisa Mia Peralta, Sep 25, 2011.

1. ### Luisa Mia PeraltaNew Member

Joined:
Sep 25, 2011
Messages:
7
0
Trophy Points:
0
1) The proper divisor of an integer N are the positive divisor less than N, a positive integer is said to be DEFiCiENT, PERFECT, or ABUNDANT numbers if the sum of it's proper divisor is less than, equal to or greater than the number respectively. Write a program using function call by reference to input integer N and call function COMPUTE to determine of integer N is DEFiCiENT, PERFECT or ABUNDANT.

EXAMPLE :
Input n: 8
Proper divisors are 1,2,4
sum of proper divisors: 1 + 2 + 4 = 7
7<8 is DEFiCiENT

Input N: 6
Proper Divisors are 1,2,3
Sum of proper divisors; 1 + 2 + 3 = 6
6=6 is PERFECT

Input N: 12
Proper divisors are 1, 2, 3, 4,6
Sum of proper divisors : 1 + 2 + 3 + 4 + 6 = 16
16 > 12 ABUNDANT

Kindly answer this )

2. ### DRKNew Member

Joined:
Apr 13, 2012
Messages:
44
3
Trophy Points:
0
Code:
```void COMPUTE(int N)
{
int i, sum = 0;

printf("Proper divisors are: ");
for (i = 1; i < N; i++)
{
if (N % i == 0)
{
if (i > 1)
{
printf(", ");
}
printf("%d", i);
}
}
printf("\n");

printf("Sum of proper divisors: ");
for (i = 1; i < N; i++)
{
if (N % i == 0)
{
if (i > 1)
{
printf(" + ");
}
printf("%d", i);
sum += i;
}
}
printf(" = %d\n", sum);

if (sum < N)
{
printf("%d < %d is DEFICIENT\n", sum, N);

}
else if (sum > N)
{
printf("%d > %d is ABUNDANT\n", sum, N);
}
else
{
printf("%d == %d is PERFECT\n", sum, N);
}

}```

3. ### Luisa Mia PeraltaNew Member

Joined:
Sep 25, 2011
Messages:
7
0
Trophy Points:
0
thanks a lot DRK ! i'll try this one on my turbo c D

Joined:
Aug 8, 2011
Messages:
5