I think i figured it out or at least i am getting the right results with my test, but does this make sense to you guys?
Code:
#include <stdio.h>
#include <math.h>
void iterative(int x, int y);
int recursive (int x, int y, int remainder);
int main (void)
{
/*Define Variables*/
int x;
int y;
int remainder=1;
/*Get user Input*/
printf("Input first number-> ");
scanf("%d", &x);
printf("Input second number-> ");
scanf("%d", &y);
/* Compute */
x=abs(x);
y=abs(y);
printf("Recursive GCM = %d \n", recursive(x, y, remainder));
iterative(x,y);
/*End Program*/
return 0;
}
/*-----------------------------------------------------------*/
void iterative(int x, int y)
{
int remainder;
int gcm;
do{
remainder=x%y;
x=y;
y=remainder;
}
while(remainder!=0);
gcm=x;
printf("Iterative GCM = %d \n", gcm);
return(0);
}
/*----------------------------------------------------------*/
int recursive(int x, int y, int remainder)
{
if(remainder==0)
return x;
else
{
remainder=x%y;
x=y;
y=remainder;
return recursive(x, y, remainder);
}
}
/*--------------------------------------------------------*/