0

Hi

Have written this code for a program that requires the user to either enter 1 or 2 dependant on whether the program solves the problem of finding the divisors of any given to numbers by recursive or iteration methods.

```
#include<iostream>
using namespace std;
int recursiveGCD(int ,int );
int iterativeGCD(int ,int );
int input;
void main()
{
int x,y;
cout<<"Please enter the two numbers : ";
cin>>x>>y;
cout<<"Enter 1 for recursive calculation, 2 for iterative";
cin>>input;
{
if input == 1
return recursiveGCD;
if input == 2
return iterativeGCD;
}
cout<<"The Greatest Common Divisor of ("<<x<<","<<y<<") = " << recursiveGCD(x,y)<<endl;
}
int recursiveGCD(int x,int y)
{
if(y>x)return recursiveGCD(y,x);
if(x==y)return x;
if(x%y==0)return y;
return recursiveGCD(x,x-y);
}
int iterativeGCD(int x,int y)
{
if (y == 0)
return x;
else
return iterativeGCD(y, x % y);
}
```

However I am getting the error C2061, saying that input is undeclared when I seem to have to declared it at the top??

Many Thanks