Answer to Question #5382 in C++ for Naveed Qurban

Question #5382
1.Make program that determines whether two input numbers are coprime or not. Two numbers are coprime if the only positive number that perfectly divides them is 1. In other words, two numbers can be coprime only if their gcd is 1. 2.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. 3.Write a C++ program that can interleave bits of two entered 16 bit variable and stores the result in a 32 bit variable. For example, if user provides x and y, then the resulting number has bits of x at even position and bits of y at odd position
#include <iostream.h>
void main(){
int A, B, minAB;
int i;
bool prime = true;
cout<<"Enter number A: ";
cin>>A;
cout<<"Enter number B: ";
cin>>B;
if (A<=B) minAB = A;
else minAB = B;
i=2;
while ((i<=minAB)&&(prime==true)){
& if ((A%i==0)&&(B%i==0)) prime = false;
& i++;
}
if (prime == true) cout<<"A and B are coprime.";
else cout<<"A and B are not coprime.\r\n";
}

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!