Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Euclids Algorithm solves the problem of finding the greatest common divisor of two non-negative, non-zero integers. You will create a program that will calculate the

Euclids Algorithm solves the problem of finding the greatest common divisor of two non-negative, non-zero integers. You will create a program that will calculate the greatest common divisor of two integers based on Euclids Algorithm.

SPECIFICATIONS Your source code should be contained in a single file and should be named your TTU email address excluding the @students.tntech.edu and an underscore and an A to indicate part A (example: acrockett_A.cpp). Write a C++ program to find the greatest common divisor of two numbers m and n based on Euclids algorithm. Your program should be able to calculate the greatest common divisor for all inputs for which it is defined; you may assume the input values can be stored in an int data type. Your program will take in two command arguments specifying the value of m and n, and will write to standard output the text gcd([m],[n]) = [v] where [m], [n], and [v] are the values of m, n, and gcd(m,n), respectively. In the case where the greatest common divisor is not defined, you will print the text gcd([m],[n]) is undefined.

PART B FIND GCD USING CONSECUTIVE INTEGER CHECKING ALGORITHM DESCRIPTION Consecutive Integer Checking Algorithm also solves the problem of finding the greatest common divisor of two non-negative, non-zero integers. You will create a program that will calculate the greatest common divisor of two integers based on the Consecutive Integer Checking Algorithm.

SPECIFICATIONS Your source code should be contained in a single file and should be named your TTU email address excluding the @students.tntech.edu and an underscore and a B to indicate part B (example: acrockett_B.cpp). Write a C++ program to find the greatest common divisor of two numbers m and n based on the Consecutive Integer Checking Algorithm. Your program should be able to calculate the greatest common divisor for all inputs for which it is defined; you may assume the input values can be stored in an int data type. Your program will take in two command arguments specifying the value of m and n, and will write to standard output the text gcd([m],[n]) = [v] where [m], [n], and [v] are the values of m, n, and gcd(m,n), respectively. In the case where the greatest common divisor is not defined, you will print the text gcd([m],[n]) is undefined. Refer to the sample output.

image text in transcribed

image text in transcribed

CWindows System321cmd.exe : \Users acrockett\Desktop|CSC CSC Fall 2018\CSC2400\PROGRAMS>run 943857 384 gcd (943857, 384) is :\Users\acrockett\Desktop\CSC\CSC Fall 2018\CSC2400\PROGRAMS>run gcd (e, e) is undefined

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

More Books

Students also viewed these Databases questions