{"id":35188,"date":"2016-04-06T22:34:02","date_gmt":"2016-04-07T03:34:02","guid":{"rendered":"http:\/\/diegodamy.wordpress.com\/?p=283"},"modified":"2016-04-06T22:43:49","modified_gmt":"2016-04-07T03:43:49","slug":"gcd-what-were-you","status":"publish","type":"post","link":"https:\/\/kenscourses.com\/tc101winter2016\/2016\/04\/gcd-what-were-you\/","title":{"rendered":"GCD: What were you?"},"content":{"rendered":"<p>#TC1017 #QUIZ6<\/p>\n<p>Soooo I had no idea what a GDC was, well I had forgotten what it was. Lucky for me Euclide&#8217;s formula was quite easy to understand anfd implement, so I chose to do it with arrays, just cause.<\/p>\n<p>It was simple and effective, but I did struggle with a compiling error that was due to a bad implementation of some logic. (When either number is 0). I just had to rearrange some lines of code and it ran like a charm.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-294\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/04\/01b90cac09614cf07cfafe5f9602f885.jpg\" alt=\"quiz6\"   \/><\/p>\n<p>Source Code below: [GitHub Link: \u00a0https:\/\/github.com\/diegodamy\/Quiz6]<\/p>\n<p>#include &lt;iostream&gt;<br \/>\nusing namespace std;<\/p>\n<p>int GetGDC(int numbers[], int size){<br \/>\nint quotient;<br \/>\nint modulus;<\/p>\n<p>do {<\/p>\n<p>if (numbers[0] == 0){<br \/>\nreturn 1; \/\/cout &lt;&lt; &#8220;GDC is &#8221; &lt;&lt; numbers [1] &lt;&lt; endl;<br \/>\n} else if (numbers[1] == 0){<br \/>\nreturn 0; \/\/cout &lt;&lt; &#8220;GDC is &#8221; &lt;&lt; numbers [0] &lt;&lt; endl;<br \/>\n}<\/p>\n<p>quotient = numbers[0]\/numbers[1];<br \/>\nmodulus = numbers[0]%numbers[1];<\/p>\n<p>numbers [0] = (numbers [1]*quotient)+modulus;<\/p>\n<p>numbers [0] = numbers [1];<br \/>\nnumbers [1] = modulus;<\/p>\n<p>} while ((numbers[0] == 0)||(numbers[1] == 0));<\/p>\n<p>}<\/p>\n<p>int main(){<br \/>\nint array [2];<\/p>\n<p>cout &lt;&lt; &#8220;In order to find the GCD of two numbers, please input two positive integers:&#8221; &lt;&lt; endl;<br \/>\nfor (int i=0; i&lt;2; i++) {<br \/>\ncin &gt;&gt; array[i];<br \/>\n}<\/p>\n<p>if (GetGDC(array,2)==1) {<br \/>\ncout &lt;&lt; &#8220;The GDC of given numbers is &#8221; &lt;&lt; array[1] &lt;&lt; endl;<br \/>\n} else if (GetGDC(array,2)==0) {<br \/>\ncout &lt;&lt; &#8220;The GDC of given numbers is &#8221; &lt;&lt; array[0] &lt;&lt; endl;<br \/>\n} else {<br \/>\ncout &lt;&lt; &#8220;The GDC of the given numbers is &#8221; &lt;&lt; GetGDC(array,2) &lt;&lt; endl;<br \/>\n}<br \/>\n}<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/p>\n<div class=\"html\">Photo Credit: &lt;a href=&#8221;<a href=\"https:\/\/www.flickr.com\/photos\/46210293@N08\/7191400326\/&#8221;&gt;rolfekolbe&lt;\/a&#038;%23038;gt\" rel=\"nofollow\">https:\/\/www.flickr.com\/photos\/46210293@N08\/7191400326\/&#8221;&gt;rolfekolbe&lt;\/a&#038;gt<\/a>; via &lt;a href=&#8221;<a href=\"http:\/\/compfight.com&#038;\/#8221;&gt;Compfight&lt;\/a&#038;%23038;gt\" rel=\"nofollow\">http:\/\/compfight.com&#8221;&gt;Compfight&lt;\/a&#038;gt<\/a>; &lt;a href=&#8221;<a href=\"https:\/\/creativecommons.org\/licenses\/by-nc\/2.0\/&#8221;&gt;cc&lt;\/a&#038;%23038;gt\" rel=\"nofollow\">https:\/\/creativecommons.org\/licenses\/by-nc\/2.0\/&#8221;&gt;cc&lt;\/a&#038;gt<\/a>;<\/div>\n<p>  <a rel=\"nofollow\" href=\"http:\/\/feeds.wordpress.com\/1.0\/gocomments\/diegodamy.wordpress.com\/283\/\"><img decoding=\"async\" alt=\"\" border=\"0\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/04\/bccf5a266e9e1d68fa35b361e4616869.jpg\" \/><\/a> <img loading=\"lazy\" decoding=\"async\" alt=\"\" border=\"0\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/04\/570a4841ea02662b5e8b880ab5031cf4.jpg#038;blog=105336245&#038;%23038;post=283&#038;%23038;subd=diegodamy&#038;%23038;ref=&#038;%23038;feed=1\" width=\"1\" height=\"1\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>#TC1017 #QUIZ6 Soooo I had no idea what a GDC was, well I had forgotten what it was. Lucky for me Euclide&#8217;s formula was quite easy to understand anfd implement, so I chose to do it with arrays, just cause. It was simple and effective, but I did struggle with a compiling error that was &hellip; <a href=\"https:\/\/kenscourses.com\/tc101winter2016\/2016\/04\/gcd-what-were-you\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">GCD: What were you?<\/span><\/a><\/p>\n","protected":false},"author":20,"featured_media":35198,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,4],"tags":[32,223],"class_list":["post-35188","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blogs","category-syndicated","tag-tc1017","tag-quiz6"],"_links":{"self":[{"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/posts\/35188","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/users\/20"}],"replies":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/comments?post=35188"}],"version-history":[{"count":2,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/posts\/35188\/revisions"}],"predecessor-version":[{"id":35203,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/posts\/35188\/revisions\/35203"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/media\/35198"}],"wp:attachment":[{"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/media?parent=35188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/categories?post=35188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/tags?post=35188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}