J
Joe Smith
#include <stdio.h>
int main(void)
{
unsigned long gcd(unsigned long m, unsigned long n);
unsigned long m;
unsigned long n;
unsigned long t;
m = 2520;
n = 154;
t = gcd(m, n);
printf("%f is gcd\n", t);
return 0;
}
unsigned long gcd(unsigned long m, unsigned long n)
{
if(m < n)
{
unsigned long temp = m;
m = n;
n = temp;
}
if(n > 0)
{
unsigned long r;
do
{
r = m % n;
m = n;
n = r ? r : n;
} while(r > 0);
}
return n;
}
/* end code */
This compiles and behaves with the exception of the printf. I've scoured
K&R print flags to %% and am out of guesses. Joe
int main(void)
{
unsigned long gcd(unsigned long m, unsigned long n);
unsigned long m;
unsigned long n;
unsigned long t;
m = 2520;
n = 154;
t = gcd(m, n);
printf("%f is gcd\n", t);
return 0;
}
unsigned long gcd(unsigned long m, unsigned long n)
{
if(m < n)
{
unsigned long temp = m;
m = n;
n = temp;
}
if(n > 0)
{
unsigned long r;
do
{
r = m % n;
m = n;
n = r ? r : n;
} while(r > 0);
}
return n;
}
/* end code */
This compiles and behaves with the exception of the printf. I've scoured
K&R print flags to %% and am out of guesses. Joe