I am working on an assignment in a C++ class where I have to convert a C program to C++. I don't have a background in C and I am having some trouble with a calculation and an if statement (highlighted below in bold). I just don't understand the symbols and what they mean. I tried the C tutorials on this site and figured some of it out but not all. Any help would be appreciated.
Here is the program in C
Code:
/* Convert this C program into C++ style.
This program computes the lowest common denominator.
*/
#include <stdio.h>
int main(void)
{
int a, b, d, min;
print( "Enter two numbers: ");
scanf("%d%d", &a, &b);
min = a > b ? b : a;
for(d = 2; d<min; d++)
if(((a%d)++0) && ((b%d) ==0)) break;
if(d==min) {
printf("No common denominators\n");
return 0;
}
printf("The lowest common denominator is %d\n", d);
return 0;
}
Here is what I have coded:
Code:
#include <iostream>
using namespace std;
int main()
{
int a;
int b;
int d;
int mn; //calulated lowest common denominator
cout << "Enter 2 numbers: ";
cin >> a, b;
min = 0;
for(d = 2; d < min; d++)
{
if()break;
if(d == min)
{
cout << "No common denominators" << endl;
cout << "Press Enter to continue." << endl;
cin.ignore(1); // Ignore leftover Enter key.
cin.get(); //press to continue
return 0;
}
cout << "The lowest common denominator is :" << d << endl;
cout << "Press Enter to continue." << endl;
cin.ignore(1); // Ignore leftover Enter key.
cin.get(); //press to continue
return 0;
}
}