C Online Compiler
Example: ABUNDANT Number or Not in C using Function
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// ABUNDANT Number or Not in C using Function #include <stdio.h> void is_abundant_number(int number) { int sum = 0, i = 1; // Calculate the sum of divisors of the input number while (i < number) { if (number % i == 0) sum += i; i++; } // Compare the input number with the sum of its divisors if (sum > number) { printf("\n%d IS AN ABUNDANT NUMBER", number); printf("\nABUNDANCE = %d\n", sum - number); } else printf("\n%d IS NOT AN ABUNDANT NUMBER!\n", number); } // It's the main function of the program int main() { int number; // Step-1 Take an input from the User printf("INPUT A NUMBER: "); scanf("%d", &number); // Step-2 Call the is_abundant_number(); function check input number is ABUNDANT or Not is_abundant_number(number); return 0; }
25
Output
Clear
ADVERTISEMENTS