4. GCD * LCM = a*b
Where * is the multiplication symbol.
Suppose that the user only enters 3 out of 4 values and -1 for the 4th value. You have to print the 4th value on the basis of the entered values. For example if the user enters 3 and 6 for the values a and b and 3 and -1 for the gcd and lcm then the value of lcm would be 6.
// StudentName.cpp : Defines the entry point for the console
application.
//
#include "stdafx.h"
#include "conio.h"
#include
<iostream>
#include "string"
using namespace std;
int
_tmain(int argc, _TCHAR* argv[])
{
double
a,b,gcd,lcm;
cout<<"Enter number
a=";
cin>>a;
cout<<"Enter number
b=";
cin>>b;
cout<<"Enter number
gcd=";
cin>>gcd;
cout<<"Enter number lcm(enter
-1)=";
cin>>lcm;
if(lcm==-1){
lcm=a*b/gcd;
cout<<lcm;
}
getch();
return
0;
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
C++