A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Write a program in C to check whether a given number is Deficient or not a Deficient number
Q:

Write a program in C to check whether a given number is Deficient or not a Deficient number

0

Write a program in C to check whether a given number is Deficient or not


Expected Output :
Input an integer number: 15
The number is Deficient.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

# include <stdio.h>
# include <stdbool.h>
# include <math.h>

int getSum(int n)
{
    int sum = 0;
    for (int i=1; i<=sqrt(n); i++)
    {
        if (n%i==0)
        {
            if (n/i == i)
                sum = sum + i;
            else 
            {
                sum = sum + i;
                sum = sum + (n / i);
            }
        }
    }
    sum = sum - n;
    return sum;
}
bool checkDeficient(int n)
{
    return (getSum(n) < n);
}
int main()
{
int n;
  printf("\n\n Check whether a given number is Deficient or not:\n");
  printf(" -----------------------------------------------------\n");
  printf(" Input an integer number: ");
  scanf("%d",&n);
    checkDeficient(n)?   printf(" The number is Deficient.\n") :   printf(" The number is not Deficient.\n");
    return 0;
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now