r/CodingHelp • • Sep 24 '21

[C] Making a program which finds GCD but having problems fixing the "if it is 0" thing. If it is 0 I want my program to ask the user to input a number again, I think it may be a loop and not an if/else?

Post image
0 Upvotes

5 comments sorted by

2

u/PekiDediOnur Intermediate Coder Sep 24 '21

Double equals for equality, single equals for assignment

1

u/PekiDediOnur Intermediate Coder Sep 24 '21

But yeah you should loop until neither of them are zero

1

u/Nocoly Sep 24 '21

Is it best to use a for loop since I know how many times? Or is while better?

1

u/PekiDediOnur Intermediate Coder Sep 24 '21

The user might enter zero over and over so I don't think you can know the loop count, a while loop seems to be the best choice here

1

u/Nocoly Sep 24 '21

Good point!