Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

WE have to write a program to find the GCD. I could use some tips or step by ste

ID: 3616870 • Letter: W

Question

WE have to write a program to find the GCD. I could use some tips or step by step hints on how tostart
INSTRUCTIONS : Greatest Common Divisor ?? Recursive algorithm for finding theGCD of two positive integers, x andy: If x is a multiple of y, their GCD is y. Otherwise, their GCD is the GCD of y and (x mody).
?? Write a recursive function, GCD, tocompute the greatest common divisor of twopositive integers. ?? Function GCD should take twointeger parameters and return an integer that isthe greatest common divisor of the twoinput values. int GCD (int x, int y);
?? Provide a function to get a postiveinteger greater than zero from the keyboardand return it to the caller. int get_input() ?? If input is not valid, the functionshould output an error message and ask the useto try again for that input. ?? Output a prompt in main() prior tocalling this function. ?? Be sure your input functionworks correctly with invalidinputs. ?? Even inputs that are notintegers ?? 123.456 (Should return123) ?? abc (Should output errormessage and repeat input.) ?? Clear the keyboard input bufferafter getting an invalid value.
Implementation Requirements ?? In your main() function ?? Prompt the user for input X and callfunction get_input() to get a nonzero positive integer fromkeyboard. ?? Prompt the user for input Y and callfunction get_input() to get a nonzero positive integer fromkeyboard. ?? Call GCD() to get the greatest commondivisor of X and Y. ?? Output the result. ?? End run. ?? See sample run fordetails. ?? Make your program match the samplerun.



CAN SOMEONE HELP ME ADD THE REST TOTHIS? THIS IS WHAT I WROTE SO FAR: #include <stdio.h>
int main() {
  double int_y, int_x;

  printf("This program computes the greatestcommon divisor ");   printf("of positive integers x and y, enteredby the user ");   printf("Inpites must be integers greater thanzero ");   printf("Enter integer x: ");   scanf("%lf",int_x);
  printf("Enter integer y: ");   scanf("%lf",int_y);
return 0; } #include <stdio.h>
int main() {
  double int_y, int_x;

  printf("This program computes the greatestcommon divisor ");   printf("of positive integers x and y, enteredby the user ");   printf("Inpites must be integers greater thanzero ");   printf("Enter integer x: ");   scanf("%lf",int_x);
  printf("Enter integer y: ");   scanf("%lf",int_y);
return 0; }

Explanation / Answer

please rate - thanks # include #include int gcd(int,int); int getinput(); int main() {    int x;          int y;            printf("This program computes the greatest commondivisor "); printf("of positive integers x and y, entered by theuser "); printf("Inputes must be integers greater thanzero ");      printf("Enter integer x: ");    x=getinput();    printf("Enter integer y: ");    y=getinput();    printf(" The GCD of %d and %d is %d ",x,y,gcd(x,y));   getch();                                     //use this, needs conio to be included    return 0; } int getinput() { double x; while(scanf("%lf",&x)!=1||xb)               a -= b;           else               b -= a;      } return a; }