Last active
April 10, 2016 18:58
-
-
Save Zulqurnain/3da99db0fafd43af6aed to your computer and use it in GitHub Desktop.
Program to Convert Mixed Number into Numerator and Denominator Form.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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