jwdcfdeveloper
Programmer
I am getting errors w/ my code concerning an undeclared parameter and a parse error.
Here's the code:
#include "iostream"
using namespace std;
int findgcd(int a, int b) {
int r,q,x0_old,y0_old,y1_old,gcd;
int x0 = 1;
int x1 = 0;
int y0 = 1;
int y1 = 0;
r = a mod b;
do {
q = (a-r)/b;
a = b;
b = r;
x0_old = x0;
y0_old - y0;
x0 = x1;
y0 = y1;
x1 = x0_old - (q*x1);
y1 = y1_old - (q*y1);
r = a mod b;
} while (r != 0);
gcd = b;
return(gcd);
}
int main()
{
int z;
z = findgcd(11,7);
cout << "The GCD is: " << z;
return 0;
}
Here are the primary errors:
12 c:\docume~1\jamesw~1\mydocu~1\csc309\prob2.cpp
`a' undeclared (first use this function)
12 c:\docume~1\jamesw~1\mydocu~1\csc309\prob2.cpp
parse error before `b'
I am not sure why 'a' is undeclared, and I assume the the second error is related to the first. Does anyone have any ideas about solving this one?
Here's the code:
#include "iostream"
using namespace std;
int findgcd(int a, int b) {
int r,q,x0_old,y0_old,y1_old,gcd;
int x0 = 1;
int x1 = 0;
int y0 = 1;
int y1 = 0;
r = a mod b;
do {
q = (a-r)/b;
a = b;
b = r;
x0_old = x0;
y0_old - y0;
x0 = x1;
y0 = y1;
x1 = x0_old - (q*x1);
y1 = y1_old - (q*y1);
r = a mod b;
} while (r != 0);
gcd = b;
return(gcd);
}
int main()
{
int z;
z = findgcd(11,7);
cout << "The GCD is: " << z;
return 0;
}
Here are the primary errors:
12 c:\docume~1\jamesw~1\mydocu~1\csc309\prob2.cpp
`a' undeclared (first use this function)
12 c:\docume~1\jamesw~1\mydocu~1\csc309\prob2.cpp
parse error before `b'
I am not sure why 'a' is undeclared, and I assume the the second error is related to the first. Does anyone have any ideas about solving this one?