You can modify your function to take 2 argument instead of 1 as shown below. First argument corresponds to the starting number and second corresponds to the ending number.
#include <iostream>
using namespace std;
//function uniquePairs takes 2 arguments now instead of just 1
void uniquePairs(int startingNumber, int endingNumber) {
int k = 0;
for (int i = startingNumber; i <= endingNumber; ++i) {
for (int j = startingNumber + k; j<= endingNumber; j++) {
cout << "(" << i << "," << j << ")" << endl;
}
++k;
}
}
int main() {
int startingNumber, endingNumber;
std::cout<<"Enter startingNumber: "<<std::endl;
std::cin >> startingNumber;
std::cout<<"Enter endingNumber: "<<std::endl;
std::cin >> endingNumber;
//call the function while passing the 2 input numbers
uniquePairs(startingNumber,endingNumber);
return 0;
}
The output of the above program for inputs startingNumber =1
and endingNumber = 5
is:
Enter startingNumber:
1
Enter endingNumber:
5
(1,1)
(1,2)
(1,3)
(1,4)
(1,5)
(2,2)
(2,3)
(2,4)
(2,5)
(3,3)
(3,4)
(3,5)
(4,4)
(4,5)
(5,5)
The output of the above program can be seen here. Also take a look at Why should I not #include <bits/stdc++.h>?.