
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
Check if a given number is Pronic in C++
Here we will see, how to check whether a number is Pronic number or not. A number that can be arranged to form a rectangle, are called the pronic numbers. First few pronic numbers are: 0, 2, 6, 12, 20, 30, 42, 56, 72, 90, 110, 132, 156, 182, 210, 240, 272, 306, 342. The pronin numbers are product of two consecutive integers. So a pronic number n = x * (x + 1).
Here we will check and generate some pronic numbers.
Example
#include <iostream> #include <cmath> using namespace std; bool isPronicNumber(int num) { for (int i = 0; i <= (int)(sqrt(num)); i++) if (num == i * (i + 1)) return true; return false; } int main() { for (int i = 0; i <= 200; i++) if (isPronicNumber(i)) cout << i << " "; }
Output
0 2 6 12 20 30 42 56 72 90 110 132 156 182
- Related Articles
- How To Check Whether a Number Is a Pronic Number or Not in Java?
- Check if a given mobile number is fancy in C++
- Check if a given string is a valid number in Python
- Check if a given string is a valid number in C++
- Java Program for check if a given number is Fibonacci number?
- Check if a given number is sparse or not in C++
- Check if given number is perfect square in Python
- How to check if a given number is a Fibonacci number in Python Program ?
- Check if given number is Emirp Number or not in Python
- Check if the given number is a perfect cube: $216$.
- Python program to check if the given number is a Disarium Number
- Check if a number is in given base or not in C++
- Check if the given number is Ore number or not in Python
- How to check if a given character is a number/letter in Java?
- Python Program for How to check if a given number is a Fibonacci number?

Advertisements