QUIZ#6, Euclide algorythm

quiz6
Resumiendo las instrucciones, deberíamos crear un código que recibe dos números o parámetros por parte del usuario, a continuación, en una función se va a imprimir el mayor denominador que divide a ambos números.

quiz6compile

CÓDIGO:

 

#include <iostream>

using namespace std;

 

int euclidianAlgo(int first, int second){

int tem=0;

int res=first%second;

while(res!=0){

first=second;

second=res;

res=first%second; }

 

return second; }

 

 

 

int main() {

int first, second, val;

cout<<“This program does the Euclidian Algorithm of the range of numbers you give”<<endl;

cout<<“Type the lower value”<<endl;

cin>>first;

cout<<“Ok now type the higher value”<<endl;

cin>>second;

val=euclidianAlgo(first, second);

cout<<“The greatest denominator of the two numbers is: “<<” “<<val<<endl; }

CC BY-SA 4.0 QUIZ#6, Euclide algorythm by valevazquezruiz is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.