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

My assignment is to use the template in the assignment and the pseudocode for Eu

ID: 3621153 • Letter: M

Question

My assignment is to use the template in the assignment and the pseudocode for Euclid's Algorithm, found in the module 3 commentary under “III. Loop Statements, A. The while Loop,” to write a C++ program that computes the greatest common divisor (GCD) of two numbers. Maintain all the blank lines, spaces, and general alignment in the template. Replace the areas that have been highlighted in yellow with your code. Do not change any of the other code
.
Remember that if you are using Microsoft Visual C++ Express Edition, this will need to be a Win32 Console application, and that you must also add #include “stdafx.h” at the start of the program.

Note: If you look at the code you will see that if either of the numbers for which a GCD is to be found is 0, the algorithm does not work correctly because you divide by 0. Dividing by 0 is mathematically undefined, and will result in a run time error when your program runs (Windows will ask if you want to report the error to Microsoft. I recommend against that). You must insert code to determine if either number input is 0, and print an error message and stop the program if either is 0. The c++ instruction to stop execution for an error condition is return (-1);

Once your program is working, test it with all of test data given in the programming assignment, and execute the code with the test data to determine that it is working correctly. Note that there are 14 test cases, and you will need to run each of the 14. The 14 test cases do not have data to test the error trapping to detect input values of 0. You need three more test cases to detect this, and you will be responsible for creating those three, and using them with your program to confirm that it executes correctly. This means you will need to run your program 17 times.
What You Need to Submit

Create a Word 97-2003 file. Using copy and paste, place a copy of your source code into this word file. On separate pages in the same file, paste a copy of an alt PrtSc image taken when your program was executed with each of the 17 cases. Submit this Word file.

Explanation / Answer

please rate- thanks

without the template or the test data this is the best I can do

# include <iostream>
using namespace std;
int gcd(int,int);
int main()
{ int x;       
   int y;        
cout<<"Enter integer x: ";
   cin>>x;
   if(x<=0)
       return -1;
   cout<<"Enter integer y: ";
   cin>>y;
   if(y<=0)
       return -1;
   cout<<"The GCD of "<<x<<" and "<<y<<" is "<<gcd(x,y) <<endl;
system("pause");
return 0;
  
}

int gcd(int a, int b)    
{
    while (a != b)
      if (a > b)
          a -= b;
       else
          b -= a;
return a;
}       

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote