{"id":5650,"date":"2022-02-12T23:05:00","date_gmt":"2022-02-12T17:35:00","guid":{"rendered":"https:\/\/www.codingbroz.com\/?p=5650"},"modified":"2022-02-12T15:51:26","modified_gmt":"2022-02-12T10:21:26","slug":"cpp-program-to-find-gcd-of-two-numbers","status":"publish","type":"post","link":"https:\/\/www.codingbroz.com\/cpp-program-to-find-gcd-of-two-numbers\/","title":{"rendered":"C++ Program to Find GCD of Two Numbers"},"content":{"rendered":"\n

In this post, we will learn how to find the GCD of two numbers using C++<\/strong> Programming language.<\/p>\n\n\n\n

The greatest common divisor (GCD)<\/strong> of two nonzero integers ‘a<\/strong>‘ and ‘b<\/strong>‘ is the greatest positive integer ‘d<\/strong>‘ such that d<\/strong> is a divisor of both ‘a<\/strong>‘ and ‘b<\/strong>‘. The GCD of ‘a<\/strong>‘ and ‘b<\/strong>‘ is denoted by gcd(a, b)<\/strong>. For example: The GCD of 6<\/strong> and 9<\/strong> is 3<\/strong>.<\/p>\n\n\n\n

We will calculate the gcd of two numbers using the following approaches:<\/p>\n\n\n\n

  1. Using For Loop <\/li>
  2. Using While Loop<\/li><\/ol>\n\n\n\n

    So, without further ado, let\u2019s begin this tutorial.<\/p>\n\n\n\n

    \n