CPPForSchool.com: Flow of Control Set 2: Assignment 8
8.
Write a program to calculate HCF of Two given number.
Before I began coding, I had to confirm the meaning of HCF. According to my research, HCF stands for Highest Common Factor or another well-known synonym would be GCD or Greatest Common Denominator. Ultimately, I need to create a program that accepts two integers and then calculates the Greatest Common Denominator for both values.
For example, if the numbers inputted were 6 and 12, the HCF/GCD would be 6 because 6 can divide into itself and 12.
Below is my source and test outputs. Of course, I have also included the sample source and output for comparison.
Before I began coding, I had to confirm the meaning of HCF. According to my research, HCF stands for Highest Common Factor or another well-known synonym would be GCD or Greatest Common Denominator. Ultimately, I need to create a program that accepts two integers and then calculates the Greatest Common Denominator for both values.
For example, if the numbers inputted were 6 and 12, the HCF/GCD would be 6 because 6 can divide into itself and 12.
Below is my source and test outputs. Of course, I have also included the sample source and output for comparison.
Comments
Post a Comment