Finds the Least Common Multiple for any two numbers given.
#include <iostream>
using namespace std;
int main ()
{
loop:
int emr, n1, n2, t, n11, n22, q;
cout << "Please enter the First Number ";
cin >> n1;
cout << "Please enter the Second Number ";
cin >> n2;
if (n1 < n2)
{
t = n1;
n1 = n2;
n2 = t;
}
n11 = n1;
n22 = n2;
while (n22 != n11)
{
if (n11 > n22)
{
n22 = n22 + n2;
goto hai;
}
if (n11 < n22)
{
n11 = n11 + n1;
goto hai;
}
hai:
emr++;
}
cout << "The common factor is " << n11 << ".\n";
cout << "Enter 0 to end the program, ";
cout << "and 1 to start again: ";
cin >> q;
if (q == 1)
goto loop;
else
return 0;
}
I found this site helpful Neptune: http://www.cplusplus.com/doc/tutorial/
And there's some video tuts here: http://xoax.net/comp/cpp/console/index.php