I am trying to create a program that finds the GCD of two numbers using the brute force...
So far i have this but my problem (I hope) is that i cant get the value of g into int main()
Here is my program. Any suggestions?
#include <cstdio>
#include "simpio.h"
#include "strlib.h"
int GCD(int x, int y)
{
int g;
g = x;
while (x % g != 0 || y % g != 0)
{
g--;
}
return(g);
}
int main()
{
int n1,n2;
printf("1st number = ");
scanf("%d",&n1);
printf("2nd number = ");
scanf("%d",&n2);
printf("The GCD of %d and %d is %d",n1,n2,GCD(g));
return 0;
system("pause");
}