Skip to content

Instantly share code, notes, and snippets.

@Zulqurnain
Last active April 10, 2016 18:58
Show Gist options
  • Save Zulqurnain/3da99db0fafd43af6aed to your computer and use it in GitHub Desktop.
Save Zulqurnain/3da99db0fafd43af6aed to your computer and use it in GitHub Desktop.
Program to Convert Mixed Number into Numerator and Denominator Form.
#include <iostream>
using namespace std;
int main(void){ // coded by Zuqurnain jutt
int num=1,den=1,t1=1;
double n=0.25,t2=1; // n can be any number
for(int i=1;;i++){
t2=i*n;
t1=t2;
t2-=t1;
if(t2==0){
den=i;
num=n*den; // Numerator=Result*denominator;
break;
}
}
cout<<"Number "<<n<<" :=: "<<num<<"/"<<den<<"\n";
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment