You are on page 1of 2

hre's a uselesss bit of code:

int x = 2, y = 1, z = 4;

while (x < z)
{
z--;

while(y < 1)
{
if ((z > x + y) && (true))
{
for (int i = 12; i <= y*z+(y*x/z*y); i += (z - y))
{
if (!!!true || !!false)
cout << "woops!" << endl;
}
}
z++;
y *= x + (z + 12/4);
}

z++;
x+=y;
y = z / 2;

int x = 1;

while(x=1)
{
x = 0;

while(x=0)
{
x=1;
}
}

Does absolutely bugger-all, but it still runs.

-Angry Lawyer

/* Programmer: Gorgon
functions to find the greatest common divisor of 2
integers. The test program should read pairs of numbers
from the standard input and call gcd each time.
*/

#include <iostream.h>
using namespace std;

/*This function procude the GCD without the calculations output*/


void GCD(int a, int b)
{
int r;
cout<<"-----------------------"<<endl;
cout<<"GCD("<<a<<","<<b<<")"<<"= ";
while(r!=0)
{
r = a % b;
a = b;
b = r;
}
cout<<a<<endl;
}

/*This funtion output the calcution of the GCD numbers*/


void GCDoutput(int a, int b)
{
int r, q;

while(r!=0)
{
q = a / b;
r = a % b;
cout<<a<<"= "<<q<<" * "<<b<<" + "<<r<<endl;
a = b;
b = r;
}
}

//Main programe
int main()
{
int n1=0, n2=0;

cout<<"Enter the First Number: ";


cin>>n1;
cout<<"Enter the Secon Number: ";
cin>>n2;
cout<<"-----------------------"<<endl;
GCDoutput(n1,n2);
GCD(n1,n2);
}

the above is a working code I made to get the GREATEST COMMON DIV of 2 numbers

took me 10 mins to do it, I hop you find it usefull. :D

Resolved Question
Show me another »

Greatest Common Divisor: using assembly


language?
The greatest common divisor of two integers is the largest integer that will evenly divide both
integers. The GCD algorithm involves integer division in a loop, described by the following
C++ code:

int GCD (int x, int y)


{
x = abs(x);
y = abs(y);
do {
int n = x % y;
x = y;
y = n;
} while (y > 0);
return x;
}

Implement this function in assembly language and write a test program that calls the function
several times, passing it different values. You can store the test integers in an array. Display
all results on the screen. You output should look as follows:

First integer is: -5 Second integer is: -20 Greatest common divisor is: 5
First integer is: +18 Second integer is: +24 Greatest common divisor is: 6
First integer is: +11 Second integer is: +7 Greatest common divisor is: 1
First integer is: +438 Second integer is: +226 Greatest common divisor is: 2
First integer is: +13 Second integer is: -26 Greatest common divisor is: 13
Press

 1 year ago

You might also like