
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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 Pair of Numbers Where One is Multiple of Other in C++
Suppose we have two numbers l and r. We have to find such pair (x, y), such that l <= x, y <= r, and x != y and x divides y. If there are more than one answer, return any one of them.
So, if the input is like l = 3; r = 14, then the output will be (3, 9).
Steps
To solve this, we will follow these steps −
return l and l*2
Example
Let us see the following implementation to get better understanding −
#include <bits/stdc++.h> using namespace std; void solve(int l, int r){ cout << l << ", " << l * 2; } int main(){ int l = 3; int r = 14; solve(l, r); }
Input
3, 14
Output
3, 6
Advertisements