__gcd(int a, int b)
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int a = 18;
int b = 21;
cout << "HCF = " << __gcd(a, b) << "\n";
// cout << __gcd(18.0, 21) .................This causes error because no typecasting occurs
cout << "LCM = " << (a*b)/__gcd(a, b);
}
HCF = 3
LCM = 126
Name | Views | Likes |
---|---|---|
C++ : Find HCD and LCM in one line code | 2468 | 0 |
C++ Counting occurrences using MAP (STL) | 7085 | 0 |
C++ Splitting a sentence into words and putting into a container | 1676 | 0 |
C++ Job Sequencing with deadline (Greedy approach) | 4416 | 0 |
C++ std::wcin | 959 | 0 |
C++ std::wcout | 1300 | 1 |
C++ memset() | 314 | 0 |
C++ CHECK NUMBER IS ODD OR EVEN USING NOR | 212 | 0 |
Make C++ run faster | 357 | 1 |
Comments