program for addition of fraction(M/N + P/Q = Y/Z)



program for addition of fraction(M/N + P/Q = Y/Z)..

Answer / sreejesh1987

#include<iostream.h>
#include<conio.h>
void main()
{
int m,n,p,q,y,z;
clrscr();
cout<<"\nEnter the numerator and denominator of fraction A: ";
cin>>m>>n;
cout<<"\nEnter the numerator and denominator of fraction B: ";
cin>>p>>q;
y=m*q+n*p;
z=n*q;
int d=(y<z)?y:z;
cout<<"\nSmaller of resultant's numbers: "<<d;
int i=2;
while(i<=d)
{
while((y%i)==0&&(z%i)==0)
{
y=y/i;
z=z/i;
}
i++;
}


cout<<"\nResulting fraction is: "<<y<<"/"<<z;
getch();
}

Is This Answer Correct ?    5 Yes 1 No

Post New Answer

More C Sharp Code Interview Questions

How to find No of classes,Packages,No of Methods per Classes and Depth of Inheritance for selecting source code in windows form application using c# .net? (Source code is input Program. It may be Java or .net) Please help me..) Thanks..)

0 Answers  


. Write a program to print the following outputs using for loops $ $ $ $ $ $ $ $ $ $ $ $ $ $ $

3 Answers  


working with arrays

1 Answers  


how to get the table names via c sharp and column names also?

2 Answers   Sify,


How to Create a Treeview Menu in ASP.NET with C#?

1 Answers  






Code for Reading and writing from a file?

0 Answers   IBM, Xoriant,


Code for Working with Files under a Directory?

1 Answers  


program to check if a number is "perfect number".

1 Answers   Mind Tree, SoftSol,


c# coding for a program that takes a 3 digit number n and finds out whether the number 2^n + 1 is prime, or if it is not prime find out its factors not using the Big-integer and Exponential Function's.

1 Answers   TCS,


Write a program to count 3Letter, 4Letter and 5Letter words from a file and print the number of 3Letter, 4Letter and 5Letter words. Delimiter is space, tab, hifen. Also we should not consider the line in the file after we encounter # in that line.

0 Answers   Mind Tree,


program for string reverse(eg:- i am boy -> boy am i)

8 Answers   Black Pepper, Infosys, Mind Tree,


Can you declare an array of mixed Types?

1 Answers   HCL,


Categories
  • ASP.NET Code Interview Questions ASP.NET Code (46)
  • VB.NET Code Interview Questions VB.NET Code (9)
  • C Sharp Code Interview Questions C Sharp Code (51)
  • ADO.NET Code Interview Questions ADO.NET Code (8)