Ratio of Two Numbers
www.programmingcalculator.com
https://nikhilnihal.github.io/programmingcalculator/index.html
C++ PROGRAM TO FIND RATIO OF TWO NUMBERS
#include<bits/stdc++.h>
using namespace std;
int main()
{
int first_number, second_number,ans,t,gcd;
cin>>first_number>>second_number;
int a=first_number;
int b=second_number;
while (b != 0) {
t = b;
b = a % b;
a = t;
}
gcd = a;
printf("%d/%d",first_number/gcd,second_number/gcd);
return 0;
}
https://nikhilnihal.github.io/programmingcalculator/index.html
C++ PROGRAM TO FIND RATIO OF TWO NUMBERS
#include<bits/stdc++.h>
using namespace std;
int main()
{
int first_number, second_number,ans,t,gcd;
cin>>first_number>>second_number;
int a=first_number;
int b=second_number;
while (b != 0) {
t = b;
b = a % b;
a = t;
}
gcd = a;
printf("%d/%d",first_number/gcd,second_number/gcd);
return 0;
}
Comments
Post a Comment