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 the other number when LCM and HCF given in C++
Suppose we have a number A, and LCM and GCD values, we have to find another number B. If A = 5, LCM is 25, HCF = 4, then another number will be 4. We know that β
$$?β?=???β???$$
$$?= \frac{LCM*HCF}{A}$$
Example
#include <iostream>
using namespace std;
int anotherNumber(int A, int LCM, int GCD) {
Β Β return (LCM * GCD) / A;
}
int main() {
Β Β int A = 5, LCM = 25, GCD = 4;
Β Β cout << "Another number is: " << anotherNumber(A, LCM, GCD);
}
Output
Another number is: 20
Advertisements