Program to find GCD of floating point numbers | CPP code for finding the GCD of two floating numbers . ; Recursive function to return gcd of a and b ; base case ; Driver Function .
#include <bits/stdc++.h> NEW_LINE using namespace std ; double gcd ( double a , double b ) { if ( a < b ) return gcd ( b , a ) ; if ( fabs ( b ) < 0.001 ) return a ; else return ( gcd ( b , a - floor ( a / b ) * b ) ) ; } int main ( ) { double a = 1.20 , b = 22.5 ; cout << gcd ( a , b ) ; return 0 ; }