0

I am in a beginner C++ class and I have a homework problem where I must to find the greatest common divisor through subtraction. I am totally lost. Can anyone show me what I am doing wrong?

#include <iostream>

using namespace std;

int main ()

{

int m;

int n;

int firstNum = m;

int secondNum = n;

cout << "1st number:" << endl;

cin >> firstNum;

cout << "2nd number:" << endl;

cin >> secondNum;

while (m != 0)

{

if (n > m )

{

int t = m; m = n; n = t;

}

m = n - m;

}

cout << "the gcd of" << endl;

cout << firstNum;

cout << "and" << endl;

cout << secondNum;

cout << "is" << endl;

cout << n;

return 0;

}