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

Automatically Hyperlink URLs and E-Mail Addresses in ASP.NET Pages with C#

1 Answers  


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

1 Answers   Mind Tree,


How to pass multiple rows from one gridview to another gridview after clicking the checkbox.

1 Answers   Satyam,


How to Create Files by Using the FileInfo Class?

1 Answers  


write a Program to copy the string using switch case.

0 Answers   Mind Tree, Wipro,






How to add a value from textBox over an existing certain column in SQL Server

0 Answers  


I am developing a web application using google map api.I want to update the map inside the div control within update panel. I got other controls updated but map doesn't get updated.I do not not want to update map whenever unnecessary controls are fired at server side.How could it be achieved?

0 Answers  


Code for IP Address Comparison and Conversion in C#?

0 Answers  


Write a program which has a function and that function should take 2 or 3 or any number of strings and it should return the largest common prefix of all those strings. If there is no common prefix it should return an empty string. for eg:- INPUT OUTPUT glo {glory,glorious,glod} gl {glad,glow} {calendar,phone} empty string

2 Answers   Mind Tree,


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  


Coding for Manipulate XML File Data Using C#?

1 Answers  


Hello Sir, Thanks for the Solution but, can you pls. Explain the coding for the Static Function & static variable from the below coding....waiting for Ans. class fact { public static void Main() { fact f=new fact(); int x=1; //Declaration of x as 1 int k=Convert.ToInt32(Console.ReadLine()); for(int i=1;i<=k;i++) { x= x *i; } System.Console.WriteLine(x); } }

0 Answers  


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)