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-
- We take inputs from the user.
- We find the greatest number among the 3 given number and store it in a variable "max".
- "max" is used for the start of the "for" loop.
- 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