Monday, 18 December 2017

TO FIND GCD OF THREE NUMBER

In this blog let us see how to find the GCD (Greatest common divisor) of three number-


Sample output of the above code-


A brief explanation of the code-
  1. We take inputs from the user.
  2. We find the greatest number among the 3 given number and store it in a variable "max".
  3. "max" is used for the start of the "for" loop.
  4. The first "i" value that divides all the values a,b, and c is the GCD, hence we print it and break the loop.
For any c++ code ask me in the comments below.
I will code and give you the answer, thus making your homework easy.


No comments:

Post a Comment