- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Find unique pairs such that each element is less than or equal to N in C++

In this tutorial, we are going to learn how to find the unique pairs that are less than the given number n.

Let's see the steps to solve the problem.

Initialize the number.

Iterate from i = 1 to i < n.

Iterate from j = i + 1 to j < n.

Print the (i, j).

## Example

Let's see the code.

#include <bits/stdc++.h> using namespace std; void uniquePairs(int n) { for (int i = 1; i < n; ++i) { for (int j = i + 1; j < n; j++) { cout << "(" << i << "," << j << ")" << endl; } } } int main() { int n = 5; uniquePairs(n); return 0; }

## Output

If you execute the above program, then you will get the following result.

(1,2) (1,3) (1,4) (2,3) (2,4) (3,4)

## Conclusion

If you have any queries in the tutorial, mention them in the comment section.

- Related Questions & Answers
- C++ program to find unique pairs such that each element is less than or equal to N
- Find three integers less than or equal to N such that their LCM is maximum - C++
- Find three integers less than or equal to N such that their LCM is maximum in C++
- Find all factorial numbers less than or equal to n in C++
- Find maximum number of elements such that their absolute difference is less than or equal to 1 in C++
- Find Multiples of 2 or 3 or 5 less than or equal to N in C++
- Print all prime numbers less than or equal to N in C++
- Find maximum product of digits among numbers less than or equal to N in C++
- Print all Semi-Prime Numbers less than or equal to N in C++
- How to find numbers in an array that are greater than, less than, or equal to a value in java?
- Count ordered pairs with product less than N in C++
- Find element in a sorted array whose frequency is greater than or equal to n/2 in C++.
- Maximum product from array such that frequency sum of all repeating elements in product is less than or equal to 2 * k in C++
- Find Largest Special Prime which is less than or equal to a given number in C++
- Count pairs with bitwise OR less than Max in C++

Advertisements