From fc59dd39132c1d161f290a5edc8b2e0b47e4c0c0 Mon Sep 17 00:00:00 2001 From: Shaquille Soekhlal Date: Wed, 11 Sep 2019 11:30:23 +0200 Subject: [PATCH] Added comments --- Assignment 5/main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Assignment 5/main.c b/Assignment 5/main.c index 8883acc..6b474e0 100644 --- a/Assignment 5/main.c +++ b/Assignment 5/main.c @@ -9,14 +9,14 @@ int gcd (int p, int q) { - int r,t; - while (q > 0) + int r; + while (q > 0) /* Loops until the remainder is 0 */ { - r = p%q; - p=q; - q=r; + r = p%q; /* Calculate remainder */ + p=q; /* Storing the value of q in p */ + q=r; /* Setting q to the value of the remainder to calculate new remainder in the next iteration */ } - return p; + return p; /* Returning p after the loop finishes */ }