The program is about getting proper divisors and defining the type. Plss help

Discussion in 'C++' started by Hanix, May 16, 2016.

  1. Hanix

    Hanix New Member

    Joined:
    May 16, 2016
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    The part that shows the type of divisor does not show. Pls help
    Code:
    #include <stdio.h>
    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("Sum of proper divisors: ");
    	for (i = 1; i < N; i++)
    	{
    		if (N % i == 0)
    		{
    			if (i > 1)
    			{
    			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);
    	
    }
    int main (void)
    {
      int N;
      printf ("Input N :");
      if (scanf ("%d", &N) != 1)
      {
        printf("Bad Input");
        
      }
    
      return 0;
    }
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    Please use code blocks when posting code. What input do you give it? What output do you get? What output do you expect? What do the terms abundant, deficient and perfect mean?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice