# C++ Program to Check If Given number is Abundant or not

Table of contents

The Program in C++ Program to Check If Given number is Abundant or not is given below:

``````#include <iostream>

// Function to find the sum of proper divisors of a number
int sumOfProperDivisors(int num) {
int sum = 0;
for (int i = 1; i < num; i++) {
if (num % i == 0) sum += i;
}
return sum;
}

// Function to check if a number is abundant
bool isAbundant(int num) {
return sumOfProperDivisors(num) > num;
}

int main() {
int num;
std::cout << "Hello Codeauri Family,enter a number here to check whether the number is ugly or not!\n";
std::cin >> num;

// Check if the number is abundant
if (isAbundant(num)) {
std::cout << num << " is an abundant number." << std::endl;
} else {
std::cout << num << " is not an abundant number." << std::endl;
}

return 0;
}
``````

## Output:

Hello Codeauri Family,enter a number here to check whether the number is ugly or not!
12
12 is an abundant number.

## Pro-Tips💡

An abundant number is a number for which the sum of its proper divisors (the divisors excluding the number itself) is greater than the number itself.

The `sumOfProperDivisors` function takes a number as input and returns the sum of its proper divisors.

The `isAbundant` function takes a number as input and returns `true` if it is an abundant number and `false` otherwise.

The function uses the `sumOfProperDivisors` function to calculate the sum of the proper divisors of the number and returns `true` if the sum is greater than the number, and `false` otherwise.

### Learn C-Sharp ↗

C-sharp covers every topic to learn about C-Sharp thoroughly.

### Learn C Programming ↗

C-Programming covers every topic to learn about C-Sharp thoroughly.

### Learn C++ Programming↗

C++ covers every topic to learn about C-Sharp thoroughly.

Codeauri is Code Learning Hub and Community for every Coder to learn Coding by navigating Structurally from Basic Programming to Front-End Development, Back-End Development to Database, and many more.

## C# Program to Find Sum of Rows & Columns of a Matrix

The Program in C# Program to Find Sum of Rows & Columns of a Matrix is given below: Output: Hello Codeauri Family,enter the number of rows and columns…

## C# Program to Calculate Determinant of Given Matrix

The Program in C# Program to Calculate Determinant of Given Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns of the matrix…

## C# Program to Find Sum of right Diagonals of a Matrix

The Program in C# Program to Find Sum of right Diagonals of a Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns…

## C# Program to Find Transpose of Given Matrix

The Program in C# Program to Find Transpose of Given Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns in the matrix:22Enter…

## C# Program for Multiplication of two square Matrices

The Program in C# Program for Multiplication of two square Matrices is given below: Output: Hello Codeauri Family, enter the number of rows/columns in the matrices:2Enter the elements…

## C# Program to Delete Element at Desired position From Array

The Program in C# Program to Delete Element at Desired position From Array is given below: Output: Hello Codeauri Family, enter the number of elements in the array:4Enter…

Your Journey into Code Begins Now: Discover the Wonders of Basic Programming

X