Pyro - We have been through this many times before. Take the advice you are given, if you don't understand it then ask.
Originally Posted by
PYROMANIAC702
That is exactly what I am doing..... Please correct me if i'm wrong, but my code seems to be doing exactly that.
Ok, you are wrong. If that is exactly what you were doing, you would be getting the correct answer. Instead you just created an infinite loop. I am pretty sure the assignment doesn't say "Create a program which makes and infinite loop and doesn't solve any problems"
Originally Posted by
PYROMANIAC702
If not, could you post some code that will work?
As you have been told on your other threads, no one will do your homework for you. As a reminder, here is our homework policy. Now since I know you are not a fan of reading, I took the liberty to look at the wiki site Tater so graciously posted for you and I found this little hidden gem:
Code:
function gcd(a, b)
while b ≠ 0
t := b
b := a mod b
a := t
return a
Now since I know you don't do functions just ignore the first and last line. In fact since I know you aren't a fan of reading let me post this as:
Code:
while b ≠ 0
t := b
b := a mod b
a := t
So, if that is a while loop that does something, let's look at your while loop:
Code:
while (rem != 0)
{
if (rem == 0)
{
GCD = num2;
printf ("The GCD of %d and %d is %d", num1, num2, num2);
}
if (rem != 0)
{
num1 = num2;
num2 = rem;
}
}
Can you spot a difference? Also it would be nice of you fixed your indentation.